home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Misc / emu / Wzonka-Lad.lha / Wzonka-Lad / src / wz.s < prev    next >
Text File  |  2004-01-02  |  353KB  |  15,605 lines

  1. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2. ;                      wzonka-lad the emulator
  3. ;               GPL release. Modifications by Ventzislav Tzvetkov
  4. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5.  
  6.         incdir    "NDK_3.9:Include/include_i/"
  7.         include    "exec/memory.i"
  8.         include    "intuition/intuition.i"
  9.         include    "graphics/videocontrol.i"
  10.         include    "graphics/gfx.i"
  11.         include    "graphics/gfxbase.i"
  12.                 include "hardware/custom.i"
  13.         include    "dos/dos.i"
  14.         include    "libraries/reqtools.i"
  15.         include    "intuition/intuition_lib.i"
  16.         include    "libraries/diskfont_lib.i"
  17.         include    "graphics/graphics_lib.i"
  18.         include    "exec/exec_lib.i"
  19.         include    "libraries/lowlevel.i"
  20.         include    "libraries/lowlevel_lib.i"
  21.         include    "dos/dos_lib.i"
  22.         include    "libraries/reqtools_lib.i"
  23.         include    "libraries/xpkmaster_lib.i"
  24.         include    "xpk/xpk.i"
  25.         include    "hardware/custom.i"
  26.         include    "libraries/controlpad.i"
  27.         include    "libraries/gadtools_lib.i"
  28.         include    "graphics/displayinfo.i"
  29.  
  30.         include    "cybergraphics/cybergraphics.i"
  31.         include    "cybergraphics/cybergraphics_lib.i"
  32.  
  33.         include    "devices/inputevent.i"
  34.         include    "devices/keyboard.i"
  35.         include    "devices/serial.i"
  36.         include    "libraries/gadtools.i"
  37.         include    "exec/io.i"
  38.  
  39.         include    "libraries/ahi_lib.i"
  40.         include    "devices/ahi.i"
  41.  
  42.         incdir    "wzonka-lad_src:"
  43.         include    "screens.i"
  44.  
  45.         include    "iconstartup.i"
  46.  
  47.         include    "z80_mode.i"
  48.  
  49. GAMEBOY_DEBUG        =0                ;0 = n / 1 = y.
  50. GAMEBOY_SERIAL        =0                ;0 = n / 1 = y.
  51.  
  52. TRUE            =1
  53. FALSE            =0
  54.  
  55. INPUT_OK        =0
  56. INPUT_GBS_LOAD        =1
  57. INPUT_GBS_SAVE        =2
  58. INPUT_HALT        =3
  59.  
  60. ExecBase       equ 4
  61.  
  62. Q            =%1000000000000            ;dpf colours.
  63. sprite_memory        =3*1024                ;amount of ram / sprite.
  64.  
  65. menu_x            =304
  66. menu_y            =104+5
  67.  
  68. function_x        =384
  69. function_y        =194
  70. function_x_bm        =384
  71. function_y_bm        =193
  72. gb_screen_x        =192
  73. gb_screen_y        =176
  74. register_x        =320
  75. register_y        =160
  76. window_right_bar_x    =14
  77.  
  78. function_idcmp        =IDCMP_GADGETUP!IDCMP_GADGETDOWN!IDCMP_MOUSEMOVE!IDCMP_MOUSEBUTTONS!IDCMP_CLOSEWINDOW
  79. function_flags        =WFLG_DEPTHGADGET!WFLG_DRAGBAR!WFLG_GIMMEZEROZERO!WFLG_SMART_REFRESH!WFLG_CLOSEGADGET
  80. menu_idcmp        =IDCMP_GADGETUP!IDCMP_GADGETDOWN!IDCMP_MENUPICK!IDCMP_CLOSEWINDOW!IDCMP_VANILLAKEY
  81. menu_flags        =WFLG_CLOSEGADGET!WFLG_DEPTHGADGET!WFLG_DRAGBAR!WFLG_ACTIVATE!WFLG_SMART_REFRESH!WFLG_GIMMEZEROZERO
  82. wzonka_idcmp        =0
  83. wzonka_flags        =WFLG_DEPTHGADGET!WFLG_DRAGBAR!WFLG_SMART_REFRESH!WFLG_GIMMEZEROZERO
  84.  
  85. tput_d0_to_a1:    MACRO
  86.  
  87.         and.w    #$ff,d0
  88.         move.w    d0,d1
  89.         lsr.b    #4,d0
  90.         cmp.w    #$A,d0
  91.         blt.s    atoo_0\@
  92.         add.b    #'A'-$a,d0
  93.         bra.s    ajoo_0\@
  94. atoo_0\@:    add.b    #48,d0
  95. ajoo_0\@:    move.b    d0,(a1)+
  96.  
  97.         and.b    #%1111,d1
  98.         cmp.w    #$A,d1
  99.         blt.s    atoo_1\@
  100.         add.b    #'A'-$a,d1
  101.         bra.s    ajoo_1\@
  102. atoo_1\@:    add.b    #48,d1
  103. ajoo_1\@:    move.b    d1,(a1)+
  104.  
  105.         ENDM
  106.  
  107. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  108. ;        start
  109. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  110.  
  111. gb_emu:        movem.l    d2-d7/a2-a6,-(SP)
  112.         move.l    ExecBase,exec_base
  113.         move.l    a0,cli_load
  114.  
  115.         move.l    exec_base,a6
  116.         lea    disk_font_name,a1
  117.         moveq.l    #0,d0
  118.         jsr    OpenLibrary(a6)
  119.         move.l    d0,disk_font_base
  120.         beq.w    quit
  121.  
  122.         lea    dos_name,a1
  123.         moveq.l    #39,d0
  124.         jsr    OpenLibrary(a6)
  125.         move.l    d0,dos_base
  126.         beq.w    quit
  127.  
  128.         lea    graphics_name,a1
  129.         moveq.l    #39,d0
  130.         jsr    OpenLibrary(a6)
  131.         move.l    d0,graphics_base
  132.         beq.w    quit
  133.  
  134.         lea    intuition_name,a1
  135.         moveq.l    #39,d0
  136.         jsr    OpenLibrary(a6)
  137.         move.l    d0,intuition_base
  138.         beq.w    quit
  139.  
  140.         lea    req_tools_name,a1
  141.         moveq.l    #38,d0
  142.         jsr    OpenLibrary(a6)
  143.         move.l    d0,req_tools_base
  144.         beq.w    quit
  145.  
  146.         lea    gad_tools_name,a1
  147.         moveq.l    #38,d0
  148.         jsr    OpenLibrary(a6)
  149.         move.l    d0,gad_tools_base
  150.         beq.w    quit
  151.  
  152.         lea    low_level_name,a1
  153.         moveq.l    #0,d0
  154.         jsr    OpenLibrary(a6)
  155.         move.l    d0,low_level_base
  156.  
  157.         lea    control_pad_name,a1
  158.         moveq.l    #0,d0
  159.         jsr    OpenLibrary(a6)
  160.         move.l    d0,control_pad_base
  161.  
  162.         lea    xpk_master_name,a1
  163.         moveq.l    #0,d0
  164.         jsr    OpenLibrary(a6)
  165.         move.l    d0,xpk_master_base
  166.  
  167.         lea    cyber_name,a1
  168.         moveq.l    #0,d0
  169.         jsr    OpenLibrary(a6)
  170.         move.l    d0,cyber_base
  171.  
  172.         IFGT    GAMEBOY_SERIAL
  173.  
  174.         bsr.w    serial_allocate
  175.         tst.l    d0
  176.         bne.w    quit
  177.  
  178.         ENDIF
  179.  
  180. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  181. ;        debug init
  182. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  183.  
  184.         IFGT    GAMEBOY_DEBUG
  185.  
  186.         move.l    dos_base,a6
  187.         move.l    #debug_consol_name,d1
  188.         move.l    #MODE_NEWFILE,d2
  189.         jsr    Open(a6)
  190.         move.l    d0,debug_con_handle
  191.  
  192.         move.l    #debug_message,d2
  193.         move.l    #debug_message_end-debug_message,d3
  194.         move.l    dos_base,a6
  195.         move.l    debug_con_handle,d1
  196.         jsr    Write(a6)
  197.  
  198.         ENDIF
  199.  
  200. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  201. ;        init the wzonka game window
  202. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  203.  
  204.         lea    wzonka_window,a0
  205.         move.l    #wzonka_idcmp,nw_IDCMPFlags(a0)
  206.         move.l    #wzonka_flags,nw_Flags(a0)
  207.  
  208. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  209. ;        allocate the initial memory areas
  210. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  211.  
  212.         lea    list_default_structure,a4    ;the memory list.
  213.         lea    list_default,a5
  214.         bsr.w    allocate_list            ;allocate memory.
  215.         tst.l    d0                ;errors?
  216.         beq.w    quit                ;yes! quit!
  217.  
  218. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  219. ;        get aga status
  220. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  221.  
  222.         move.l    graphics_base,a6
  223.         move.b    $ec(a6),d0
  224.         and.b    #%100,d0
  225.         lsr.b    #2,d0
  226.         move.b    d0,aga_status            ;0 = no aga / 1 = aga.
  227.  
  228. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  229. ;        lock the pubscreen
  230. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  231.  
  232.         move.l    intuition_base,a6
  233.         sub.l    a0,a0                ;default pub screen.
  234.         jsr    LockPubScreen(a6)
  235.         move.l    d0,pub_screen_lock
  236.         beq.w    quit
  237.  
  238. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  239. ;        get visual infos and fix window sizes
  240. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  241.  
  242.         move.l    gad_tools_base,a6
  243.         move.l    d0,a0
  244.         sub.l    a1,a1                ;no tag list.
  245.         jsr    GetVisualInfoA(a6)
  246.         move.l    d0,visual_info
  247.         beq.w    quit
  248.  
  249.         move.l    pub_screen_lock,a0
  250.         lea    sc_RastPort(a0),a0
  251.         moveq.l    #0,d0
  252.         move.w    rp_TxHeight(a0),d0
  253.         move.l    d0,screen_font_y
  254.  
  255.         lea    menu_window,a0
  256.         addq.l    #3,d0
  257.         move.w    d0,nw_TopEdge(a0)
  258.         move.l    d0,d1
  259.         move.l    d0,d2
  260.         add.l    #menu_y,d1
  261.         move.w    d1,nw_Height(a0)
  262.         move.w    d1,nw_MaxHeight(a0)
  263.         lea    function_window,a0
  264.         lsl.l    #1,d0
  265.         move.w    d0,nw_TopEdge(a0)
  266.         add.l    #function_y,d2
  267.         move.w    d2,nw_Height(a0)
  268.         move.w    d2,nw_MaxHeight(a0)
  269.  
  270. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  271. ;        obtain crucial window dimensions
  272. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  273.  
  274.         lea    wzonka_window,a1
  275.  
  276.         move.l    screen_font_y,d1
  277.         addq.l    #3+2,d1
  278.         move.l    d1,window_bars_height
  279.         add.l    #144,d1
  280.         move.w    d1,nw_MinHeight(a1)
  281.         move.w    d1,wzonka_window_y
  282.  
  283.         moveq.l    #8,d1
  284.         move.l    d1,window_bars_width
  285.         add.l    #160+window_right_bar_x,d1
  286.         move.w    d1,wzonka_window_x
  287.         move.w    d1,nw_MinWidth(a1)
  288.  
  289. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  290. ;        create message port
  291. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  292.  
  293.         move.l    exec_base,a6
  294.         jsr    CreateMsgPort(a6)
  295.         move.l    d0,message_port
  296.         beq.w    quit
  297.  
  298.         move.l    d0,a1
  299.         move.l    #message_port_name,LN_NAME(a1)
  300.         move.b    #1,LN_PRI(a1)
  301.  
  302.         jsr    AddPort(a6)
  303.  
  304.         move.l    colour_message,a0
  305.         move.l    colour_message_name,LN_NAME(a0)
  306.         move.l    message_port,MN_REPLYPORT(a0)
  307.         move.w    #MN_SIZE,MN_LENGTH(a0)
  308.  
  309.         move.l    exec_base,a6
  310.         jsr    CacheClearU(a6)            ;clear the cache first.
  311.  
  312. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  313. ;        ahi inits
  314. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  315.  
  316.         bsr.w    open_ahi
  317.         move.l    d0,ahi_base
  318.         beq.s    quit            ;no AHI! Quit.
  319.  
  320.         move.l    d0,a6
  321.         sub.l    a0,a0                ;no tags.
  322.         jsr    AHI_AllocAudioRequestA(a6)
  323.         move.l    d0,ahi_request
  324.         beq.w    quit            ;can't allocate ahi request? Quit.
  325.  
  326. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  327. ;        gadtools
  328. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  329.  
  330.         move.l    gad_tools_base,a6
  331.         move.l    context_g_menu,a0
  332.         jsr    CreateContext(a6)
  333.         tst.l    d0
  334.         beq.w    quit
  335.  
  336.         move.l    context_g_sfx,a0
  337.         jsr    CreateContext(a6)
  338.         tst.l    d0
  339.         beq.w    quit
  340.  
  341.         move.l    context_g_prefs,a0
  342.         jsr    CreateContext(a6)
  343.         tst.l    d0
  344.         beq.w    quit
  345.  
  346.         move.l    context_g_gfx,a0
  347.         jsr    CreateContext(a6)
  348.         tst.l    d0
  349.         beq.w    quit
  350.  
  351.         move.l    context_g_misc,a0
  352.         jsr    CreateContext(a6)
  353.         tst.l    d0
  354.         beq.w    quit
  355.  
  356. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  357. ;        create controller data lists
  358. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  359.  
  360.         move.l    joy_label_list,a6
  361.         move.l    joy_names_list,a1        ;list structure.
  362.         lea    joy_item_list,a5
  363.         move.l    #LN_SIZE,d1
  364.         addq.w    #2,d1
  365.  
  366.         move.l    a1,LH_HEAD(a6)
  367.         move.l    a6,LN_PRED(a1)
  368.  
  369.         move.l    #joy_name_1,LN_NAME(a1)
  370.         move.l    a1,a3
  371.         add.l    d1,a1
  372.         move.l    a1,LN_SUCC(a3)
  373.         move.b    #0,(a5)+
  374.  
  375.                 moveq.l #1,d0
  376.  
  377.         tst.l    low_level_base
  378.         beq.s    no_cd32_joypad
  379.  
  380.         move.l    #joy_name_2,LN_NAME(a1)
  381.         move.l    a3,LN_PRED(a1)
  382.         move.l    a1,a3
  383.         add.l    d1,a1
  384.         move.l    a1,LN_SUCC(a3)
  385.         move.b    #1,(a5)+
  386.  
  387. no_cd32_joypad:    tst.l    control_pad_base
  388.         beq.s    no_sega_joypad
  389.  
  390.         move.l    #joy_name_3,LN_NAME(a1)
  391.         move.l    a3,LN_PRED(a1)
  392.         move.l    a1,a3
  393.         add.l    d1,a1
  394.         move.l    a1,LN_SUCC(a3)
  395.         move.b    #2,(a5)+
  396.  
  397.         move.l    #joy_name_4,LN_NAME(a1)
  398.         move.l    a3,LN_PRED(a1)
  399.         move.l    a1,a3
  400.         add.l    d1,a1
  401.         move.l    a1,LN_SUCC(a3)
  402.         move.b    #3,(a5)+
  403.  
  404. no_sega_joypad:
  405.  
  406.         move.l    #joy_name_5,LN_NAME(a1)
  407.         move.l    a3,LN_PRED(a1)
  408.         move.l    a1,a3
  409.         add.l    d1,a1
  410.         move.l    a1,LN_SUCC(a3)
  411.         move.b    #4,(a5)+
  412.  
  413.         move.l    #joy_name_6,LN_NAME(a1)
  414.         move.l    a3,LN_PRED(a1)
  415.         move.b    #5,(a5)
  416.  
  417. joy_2b_done:    move.l    a1,LH_TAILPRED(a6)
  418.         lea    LH_TAIL(a6),a5
  419.         move.l    a5,LN_SUCC(a1)
  420.  
  421. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  422. ;        close controller libraries
  423. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  424.  
  425.         move.l    exec_base,a6
  426.         move.l    low_level_base,d0
  427.         beq.s    no_strt_low
  428.         move.l    d0,a1
  429.         jsr    CloseLibrary(a6)
  430.         clr.l    low_level_base
  431. no_strt_low:    move.l    control_pad_base,d0
  432.         beq.s    no_strt_pad
  433.         move.l    d0,a1
  434.         jsr    CloseLibrary(a6)
  435.         clr.l    control_pad_base
  436. no_strt_pad:    
  437.  
  438. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  439. ;        open a font
  440. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  441.  
  442.         move.l    disk_font_base,a6
  443.         lea    font_attr,a0            ;attributes for the font.
  444.         jsr    OpenDiskFont(a6)        ;open the font.
  445.         move.l    d0,font_ptr            ;save the pointer.
  446.         bne.s    font_ok                ;open worked perfectly.
  447.  
  448.         lea    font_attr,a0            ;auxiliary font I.
  449.         move.l    #another_name,(a0)
  450.         jsr    OpenDiskFont(a6)
  451.         move.l    d0,font_ptr
  452.         bne.s    font_ok
  453.  
  454.         clr.b    font_attr_flags            ;not a proportional font.
  455.         lea    font_attr,a0            ;auxiliary font II.
  456.         move.l    #res_font_name,(a0)
  457.         jsr    OpenDiskFont(a6)
  458.         move.l    d0,font_ptr
  459. font_ok:    
  460.  
  461. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  462. ;        allocate reqtools resources for rom loading and
  463. ;        snapshot loading / saving separately
  464. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  465.  
  466.         lea    rt_list,a5
  467.         move.l    req_tools_base,a6
  468. rt_f_alc_req:    tst.l    (a5)
  469.         beq.s    rt_f_alc_done
  470.         move.l    #RT_FILEREQ,d0
  471.         moveq.l    #0,d1
  472.         jsr    rtAllocRequestA(a6)
  473.         move.l    (a5)+,a4
  474.         move.l    d0,(a4)
  475.         beq.w    quit
  476.         bra.s    rt_f_alc_req
  477.  
  478. rt_f_alc_done:    move.l    #RT_SCREENMODEREQ,d0
  479.         moveq.l    #0,d1
  480.         jsr    rtAllocRequestA(a6)
  481.         move.l    d0,request_ptr_sm
  482.         beq.w    quit
  483.  
  484. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  485. ;        create the back pattern map
  486. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  487.  
  488.         lea    back_pattern_bn,a0
  489.         move.l    back_pattern_map,a1
  490.         moveq.l    #2-1,d7
  491. back_pattern_crt:
  492.         move.l    (a0)+,d0
  493.         move.l    (a0)+,d1
  494.         moveq.l    #function_y_bm/2-1,d3
  495. back_pattern_crt_y:
  496.         moveq.l    #function_x_bm/8/4-1,d2
  497. back_pattern_crt_x_1:
  498.         move.l    d0,(a1)+
  499.         dbra    d2,back_pattern_crt_x_1
  500.         moveq.l    #function_x_bm/8/4-1,d2
  501. back_pattern_crt_x_2:
  502.         move.l    d1,(a1)+
  503.         dbra    d2,back_pattern_crt_x_2
  504.         dbra    d3,back_pattern_crt_y
  505.         add.l    #function_x_bm/8,a1        ;NOTE! ALERT!
  506.         dbra    d7,back_pattern_crt
  507.  
  508. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  509. ;        init bitmaps
  510. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  511.  
  512.         lea    info_map_rle,a0
  513.         move.l    info_map,a1
  514.         bsr.w    rle_unpack
  515.  
  516.         lea    about_map_rle,a0
  517.         move.l    about_map,a1
  518.         bsr.w    rle_unpack
  519.  
  520.         move.l    info_map_attr,a0
  521.         move.l    info_map,a1
  522.         moveq.l    #8,d0
  523.         bsr.w    init_bit_map_function
  524.  
  525.         move.l    about_map_attr,a0
  526.         move.l    about_map,a1
  527.         moveq.l    #8,d0
  528.         bsr.w    init_bit_map_function
  529.  
  530.         move.l    back_pattern_map_attr,a0
  531.         move.l    back_pattern_map,a1
  532.         moveq.l    #2,d0
  533.         bsr.w    init_bit_map_function
  534.  
  535. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  536. ;        precalc the gfx window game still colours
  537. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  538.  
  539.         move.l    graphics_base,a6
  540.         move.l    gfx_game_still_rast_port,a1
  541.         jsr    InitRastPort(a6)
  542.  
  543.         move.l    gfx_game_still_rast_port,a0
  544.         move.l    gfx_game_still_tmp_rast_port,a1
  545.         bsr.w    copy_rast_port
  546.  
  547.         move.l    gfx_game_still_map_attr,a0
  548.         lea    gfx_game_still_map,a1
  549.         move.l    #304,d1
  550.         moveq.l    #39,d2
  551.         moveq.l    #3,d0
  552.         bsr.w    init_bit_map
  553.  
  554.         move.l    gfx_game_still_map_attr,a4
  555.         lea    gfx_game_still_tmp_map_attr,a5
  556.         bsr.w    alloc_bit_map
  557.         tst.l    d0
  558.         beq.w    quit
  559.  
  560.         move.l    d0,a0
  561.         move.w    #304/8,bm_BytesPerRow(a0)
  562.         move.w    #1,bm_Rows(a0)
  563.  
  564.         move.l    gfx_game_still_rast_port,a0
  565.         move.l    gfx_game_still_map_attr,rp_BitMap(a0)
  566.         move.l    gfx_game_still_tmp_rast_port,a0
  567.         move.l    gfx_game_still_tmp_map_attr,rp_BitMap(a0)
  568.         clr.l    rp_Layer(a0)
  569.  
  570.         moveq.l    #0,d0
  571.         moveq.l    #0,d1
  572.         move.l    #303,d2
  573.         moveq.l    #38,d3
  574.         move.l    gfx_game_still_rast_port,a0
  575.         move.l    gfx_game_still_tmp_rast_port,a1
  576.         move.l    gfx_game_still_array,a2
  577.         jsr    ReadPixelArray8(a6)
  578.  
  579.         lea    gfx_game_still_tmp_map_attr,a1
  580.         bsr.w    free_bit_maps
  581.  
  582. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  583. ;        precalc
  584. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  585.  
  586.         bsr.w    do_x_flip_t
  587.  
  588. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  589. ;        collect all the packer sub library names
  590. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  591.  
  592.         tst.l    xpk_master_base
  593.         beq.w    xpk_count_xit            ;no library open - no count.
  594.  
  595.         move.l    dos_base,a6            ;time for some dos magic. ;)
  596.         move.l    #xpk_dir_name,d1        ;the name.
  597.         moveq.l    #ACCESS_READ,d2
  598.         jsr    Lock(a6)
  599.         move.l    d0,file_hd
  600.         beq.w    xpk_count_e            ;an error occurred!
  601.  
  602.         move.l    file_info_ptr,d2        ;d2 = file info structure.
  603.         move.l    d0,d1                ;d1 = file hd.
  604.         jsr    Examine(a6)            ;load file info.
  605.         tst.l    d0                ;errors?
  606.         beq.w    xpk_count_eu            ;yes! quit!
  607.  
  608.         move.l    xpk_names,a5            ;the names buffer.
  609.         move.l    file_info_ptr,a1
  610.         lea    fib_FileName(a1),a4
  611. xpk_count_exa:    move.l    file_hd,d1
  612.         move.l    file_info_ptr,d2
  613.         jsr    ExNext(a6)
  614.  
  615.         tst.l    d0                ;no errors?
  616.         beq.s    xpk_count_io            ;hmm...
  617.  
  618. xpk_count_test:    cmp.w    #'xp',(a4)            ;right start?
  619.         bne.s    xpk_count_exa            ;no. continue testing.
  620.         cmp.b    #'k',2(a4)            ;right end?
  621.         bne.s    xpk_count_exa            ;no. continue testing.
  622.  
  623. xpk_one_found:    addq.l    #1,xpk_names_v            ;one name more.
  624.         move.l    3(a4),(a5)+            ;name stored.
  625.         bra.s    xpk_count_exa            ;loop until the end comes.
  626.  
  627. xpk_count_done:    bsr.w    sort_xpk_names            ;sort the names and create
  628.         tst.l    d0                ;a list.
  629.         bne.w    quit                ;errors!
  630.  
  631.         move.l    dos_base,a6
  632.         move.l    file_hd,d1
  633.         jsr    UnLock(a6)            ;unlock it.
  634.  
  635.         bra.s    xpk_count_xit            ;normal exit.
  636.  
  637. xpk_count_io:    jsr    IoErr(a6)            ;get an error code.
  638.         cmp.l    #ERROR_NO_MORE_ENTRIES,d0    ;end of list.
  639.         beq.s    xpk_count_done            ;all done.
  640.                             ;an error occurred!
  641. xpk_count_eu:    move.l    dos_base,a6
  642.         move.l    file_hd,d1
  643.         jsr    UnLock(a6)            ;unlock it.
  644.  
  645. xpk_count_e:    move.l    exec_base,a6            ;close the library.
  646.         move.l    xpk_master_base,a1        ;it won't be used anymore.
  647.         jsr    CloseLibrary(a6)
  648.         clr.l    xpk_master_base
  649. xpk_count_xit:    
  650.  
  651. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  652. ;        load preferences
  653. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  654.  
  655.         bsr.w    prefs_load_default
  656.         bsr.w    load_game_genie_list
  657.  
  658. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  659. ;        obtain pens for the bitmaps and convert the static
  660. ;        images to use the obtained colours
  661. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  662.  
  663.         move.l    graphics_base,a6
  664.         move.l    pub_screen_lock,a5
  665.         lea    sc_ViewPort(a5),a5
  666.         move.l    vp_ColorMap(a5),a5
  667.         lea    gameboy_colours,a4        ;input (0.B, r.B, g.B, b.B).
  668.         lea    pen_list,a3            ;output (.B).
  669.         moveq.l    #8-1,d7
  670. obtain_pens:    move.l    a5,a0
  671.         lea    obtain_pens_tag_list,a1
  672.         moveq.l    #0,d1
  673.         moveq.l    #0,d2
  674.         moveq.l    #0,d3
  675.         move.b    1(a4),d1
  676.         move.b    2(a4),d2
  677.         move.b    3(a4),d3
  678.         ror.l    #8,d1
  679.         ror.l    #8,d2
  680.         ror.l    #8,d3
  681.         addq.l    #4,a4
  682.         jsr    ObtainBestPenA(a6)
  683.         move.b    d0,(a3)+
  684.         dbra    d7,obtain_pens
  685.  
  686.         move.l    gfx_game_still_array,a0
  687.         move.l    gfx_game_still_tmp_array,a1
  688.         lea    pen_list,a2
  689.         move.w    #(304*39)-1,d0
  690.         moveq.l    #0,d1
  691. convert_pens:    move.b    (a0)+,d1
  692.         move.b    (a2,d1.l),(a1)+
  693.         dbra    d0,convert_pens
  694.  
  695.         lea    pen_list,a4
  696.         move.l    (a4),pen_storage_list        ;save the pens.
  697.         move.l    4(a4),pen_storage_list+4        
  698.  
  699. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  700. ;        allocate gfx driver memory
  701. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  702.  
  703.         bsr.w    allocate_gfx_driver_memory
  704.         tst.l    d0                ;errors?
  705.         bne.w    quit                ;yes! quit!
  706.  
  707. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  708. ;        create all the gadtools buttons
  709. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  710.  
  711.         lea    menu_gadgets,a4
  712.         move.l    context_g_menu,a5
  713.         bsr.w    gadget_crt            ;create gadgets.
  714.         tst.l    d0
  715.         bne.w    quit
  716.  
  717.         move.l    gg_label_list,misc_b_code_list_tags+4
  718.         bsr.w    get_gg                ;init the list.
  719.  
  720.         lea    misc_gadgets,a4
  721.         move.l    context_g_misc,a5
  722.         bsr.w    gadget_crt            ;create gadgets.
  723.         tst.l    d0
  724.         bne.w    quit
  725.  
  726.         bchg.b    #0,snd_master            ;compability fix.
  727.         bchg.b    #0,snd_chnlI
  728.         bchg.b    #0,snd_chnlII
  729.         bchg.b    #0,snd_chnlIII
  730.         bchg.b    #0,snd_chnlIV
  731.  
  732.         lea    sfx_gadgets,a4
  733.         move.l    context_g_sfx,a5
  734.         bsr.w    gadget_crt            ;create gadgets.
  735.         tst.l    d0
  736.         bne.w    quit
  737.  
  738.         bchg.b    #0,snd_master            ;compability fix.
  739.         bchg.b    #0,snd_chnlI
  740.         bchg.b    #0,snd_chnlII
  741.         bchg.b    #0,snd_chnlIII
  742.         bchg.b    #0,snd_chnlIV
  743.  
  744.         move.l    joy_label_list,prefs_g_joy_l+4
  745.         move.l    xpk_label_list,prefs_g_xpk_l+4
  746.  
  747.         lea    prefs_gadgets,a4
  748.         move.l    context_g_prefs,a5
  749.         bsr.w    gadget_crt            ;create gadgets.
  750.         tst.l    d0
  751.         bne.w    quit
  752.  
  753.         lea    gfx_gadgets,a4
  754.         move.l    context_g_gfx,a5
  755.         bsr.w    gadget_crt            ;create gadgets.
  756.         tst.l    d0
  757.         bne.w    quit
  758.  
  759. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  760. ;        menu
  761. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  762.  
  763.         bsr.w    do_menu_items            ;create the menu lists.
  764.  
  765. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  766. ;        copy sound channel data
  767. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  768.  
  769.         move.l    smpl_mem_1,a2
  770.         move.w    #512-1,d0
  771. smpl_multiply_1:lea    smpl_bn_1,a0
  772.         move.l    (a0)+,(a2)+
  773.         move.l    (a0),(a2)+
  774.         dbra    d0,smpl_multiply_1
  775.  
  776.         move.l    smpl_mem_2,a2
  777.         move.w    #512-1,d0
  778. smpl_multiply_2:lea    smpl_bn_2,a0
  779.         move.l    (a0)+,(a2)+
  780.         move.l    (a0),(a2)+
  781.         dbra    d0,smpl_multiply_2
  782.  
  783.         move.l    smpl_mem_3,a2
  784.         move.w    #512-1,d0
  785. smpl_multiply_3:lea    smpl_bn_3,a0
  786.         move.l    (a0)+,(a2)+
  787.         move.l    (a0),(a2)+
  788.         dbra    d0,smpl_multiply_3
  789.  
  790.         move.l    smpl_mem_4,a2
  791.         move.w    #512-1,d0
  792. smpl_multiply_4:lea    smpl_bn_4,a0
  793.         move.l    (a0)+,(a2)+
  794.         move.l    (a0),(a2)+
  795.         dbra    d0,smpl_multiply_4
  796.  
  797. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  798. ;        create sound channel III table
  799. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  800.  
  801.         move.l    sound_III_lst,a0
  802.         move.w    #256-1,d0
  803.         moveq.l    #0,d1
  804. sound_III_tbl_c:move.l    d1,d2
  805.         move.l    d1,d3
  806.         and.b    #%1111,d2            ;d2 = low nibble.
  807.         lsr.b    #4,d3                ;d3 = high nibble.
  808.         lsl.b    #4,d2
  809.         lsl.b    #4,d3                ;data = data * $10.
  810.         sub.b    #128,d2
  811.         sub.b    #128,d3
  812.         move.b    d3,(a0)+            ;high byte first.
  813.         addq.b    #1,d1
  814.         move.b    d2,(a0)+            ;then the low byte.
  815.         dbra    d0,sound_III_tbl_c
  816.  
  817. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  818. ;        open windows
  819. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  820.  
  821. no_zfx_off:    move.l    intuition_base,a6
  822.         lea    menu_window,a0
  823.         lea    win_tags_u,a1            ;universal taglist.
  824.         jsr    OpenWindowTagList(a6)        ;structure and open the window.
  825.         move.l    d0,menu_ptr
  826.         beq.w    quit
  827.  
  828.         move.l    d0,a0
  829.         lea    menu_recent,a1
  830.         jsr    SetMenuStrip(a6)        ;add menus.
  831.  
  832.         move.l    graphics_base,a6
  833.         move.l    back_pattern_map_attr,a0    ;a0 = source bitmap.
  834.         move.l    menu_ptr,a1
  835.         move.l    wd_RPort(a1),a1            ;a1 = destination rastport.
  836.         moveq.l    #0,d0                ;org x.
  837.         moveq.l    #0,d1                ;org y.
  838.         moveq.l    #0,d2                ;dst x.
  839.         moveq.l    #0,d3                ;dst y.
  840.         move.l    #menu_x,d4            ;size x.
  841.         sub.l    window_bars_width,d4
  842.         move.l    #menu_y-2,d5            ;size y.
  843.         move.l    #$c0,d6                ;minterm.
  844.         jsr    BltBitMapRastPort(a6)        ;update the screen window.
  845.  
  846.         move.l    intuition_base,a6
  847.         move.l    menu_ptr,a0
  848.         move.l    wd_RPort(a0),a0
  849.         lea    menu_text_1,a1
  850.         moveq.l    #0,d0
  851.         moveq.l    #0,d1
  852.         jsr    PrintIText(a6)
  853.  
  854.         move.l    menu_ptr,a0
  855.         move.l    #-1,a1
  856.         lea    menu_scr_txt,a2
  857.         jsr    SetWindowTitles(a6)
  858.  
  859. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  860. ;        refresh the graphics
  861. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  862.  
  863.         move.l    menu_ptr,a4
  864.         lea    menu_bevel_list,a5
  865.         bsr.w    draw_bevel_list
  866.  
  867.         lea    status_waiting_txt,a5
  868.         bsr.w    print_status_middle
  869.  
  870.         move.l    intuition_base,a6
  871.         move.l    menu_ptr,a0
  872.         move.l    context_g_menu,a1
  873.         move.l    (a1),a1
  874.         sub.l    a2,a2
  875.         moveq.l    #-1,d0
  876.         moveq.l    #-1,d1
  877.         jsr    AddGList(a6)
  878.  
  879.         move.l    context_g_menu,a0
  880.         move.l    (a0),a0
  881.         move.l    menu_ptr,a1
  882.         sub.l    a2,a2
  883.         moveq.l    #-1,d0                ;all gadgets.
  884.         jsr    RefreshGList(a6)
  885.  
  886.         move.l    gad_tools_base,a6
  887.         move.l    menu_ptr,a0
  888.         sub.l    a1,a1
  889.         jsr    GT_RefreshWindow(a6)
  890.  
  891.                 moveq.l #1,d0
  892.  
  893. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  894. ;        init new bit maps for the output routines
  895. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  896.  
  897.         move.l    menu_ptr,a0
  898.         move.l    wd_RPort(a0),a0
  899.         move.l    gfx_game_still_tmp_rast_port,a1
  900.         bsr.w    copy_rast_port
  901.  
  902.         move.l    menu_ptr,a4
  903.         move.l    wd_RPort(a4),a4
  904.         move.l    rp_BitMap(a4),a4
  905.         lea    gfx_game_still_tmp_map_attr,a5
  906.         bsr.w    alloc_bit_map
  907.         tst.l    d0
  908.         beq.w    quit
  909.  
  910.         move.l    d0,a0
  911.         move.w    #304/8,bm_BytesPerRow(a0)
  912.         move.w    #1,bm_Rows(a0)
  913.  
  914.         move.l    gfx_game_still_tmp_rast_port,a0
  915.         move.l    gfx_game_still_tmp_map_attr,rp_BitMap(a0)
  916.         clr.l    rp_Layer(a0)
  917.  
  918. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  919. ;        check out the command line input from a shell
  920. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  921.  
  922.         tst.b    cli_or_wb
  923.         bne.s    get_message
  924.  
  925.         move.l    cli_load,a0
  926.         move.l    dir_n_name_ptr,a1
  927.         moveq.l    #0,d0
  928. move_name:    move.b    (a0)+,d1
  929.         beq.s    exit_name_move
  930.         cmp.b    #$a,d1
  931.         beq.s    exit_name_move
  932.         cmp.b    #" ",d1
  933.         beq.s    move_name            ;skip spaces.
  934.         move.b    d1,(a1)+
  935.         addq.w    #1,d0
  936.         bra.s    move_name
  937.  
  938. exit_name_move:    tst.w    d0
  939.         beq.s    get_message
  940.  
  941.         move.b    #0,(a1)                ;end name.
  942.         bsr.w    cli_load_here            ;load the cartridge.
  943.         bra.w    jump_g_load_aft
  944.  
  945. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  946. ;        message loop
  947. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  948.  
  949. get_message:    moveq.l    #5,d1
  950.         bsr.w    do_delay
  951.  
  952.         move.l    gad_tools_base,a6
  953.         move.l    menu_ptr,a0
  954.         move.l    wd_UserPort(a0),a0        ;userport -> a0.
  955.         jsr    GT_GetIMsg(a6)            ;get every message.
  956.         tst.l    d0                ;avoid queue.
  957.         bne.w    menu_message
  958.  
  959.         tst.b    scaling_status
  960.         beq.s    no_wzonka_ptr_msg
  961.         move.l    exec_base,a6
  962.         move.l    wzonka_ptr,d0
  963.         beq.s    no_wzonka_ptr_msg
  964.         move.l    d0,a0
  965.         move.l    wd_UserPort(a0),a0        ;userport -> a0.
  966.         jsr    GetMsg(a6)            ;get every message.
  967.         tst.l    d0                ;avoid queue.
  968.         bne.w    wzonka_message
  969.  
  970. no_wzonka_ptr_msg:
  971.         bsr.w    obtain_status            ;turn it on/off / handle
  972.                             ;messages.
  973.         tst.l    function_jmp
  974.         beq.s    get_function_message_exec
  975.  
  976.         move.l    function_ptr,d0
  977.         beq.s    get_message
  978.         move.l    d0,a0
  979.         move.l    gad_tools_base,a6
  980.         move.l    wd_UserPort(a0),a0        ;userport -> a0.
  981.         jsr    GT_GetIMsg(a6)            ;get every message.
  982.         tst.l    d0                ;avoid queue.
  983.         bne.w    function_message
  984.  
  985.         bra.w    get_message
  986.  
  987. get_function_message_exec:
  988.         move.l    function_ptr,d0
  989.         beq.w    get_message
  990.         move.l    d0,a0
  991.         move.l    exec_base,a6
  992.         move.l    wd_UserPort(a0),a0        ;userport -> a0.
  993.         jsr    GetMsg(a6)            ;get every message.
  994.         tst.l    d0                ;avoid queue.
  995.         bne.w    function_message_exec
  996.  
  997.         bra.w    get_message
  998.  
  999. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1000. ;        dos.library delay
  1001. ;        INPUT:
  1002. ;        d1    = time.
  1003. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1004.  
  1005. do_delay:    move.l    dos_base,a6
  1006.         jsr    Delay(a6)
  1007.         rts
  1008.  
  1009. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1010. ;        message from the menu window
  1011. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1012.  
  1013. menu_message:    move.l    exec_base,a6
  1014.         move.l    d0,a0
  1015.         move.l    im_Class(a0),d0
  1016.  
  1017.         cmp.l    #IDCMP_CLOSEWINDOW,d0
  1018.         beq.s    menu_quit
  1019.  
  1020.         move.l    im_IAddress(a0),d1        ;address of a gadget.
  1021.         moveq.l    #0,d2
  1022.         move.w    im_Code(a0),d2            ;menu id data.
  1023.  
  1024.         movem.l    d0-d2,-(SP)
  1025.         move.l    a0,a1                ;a1 = message.
  1026.         jsr    ReplyMsg(a6)            ;reply to it.
  1027.         movem.l    (SP)+,d0-d2
  1028.  
  1029.         cmp.l    #IDCMP_GADGETUP,d0
  1030.         beq.s    menu_buttons_x
  1031.         cmp.l    #IDCMP_MENUPICK,d0
  1032.         beq.s    menu_menu_its
  1033.         cmp.l    #IDCMP_VANILLAKEY,d0
  1034.         beq.s    menu_keys_x
  1035.         bra.w    get_message
  1036.  
  1037. menu_quit:    move.l    a0,a1                ;a1 = message.
  1038.         jsr    ReplyMsg(a6)            ;reply to it.
  1039.         bra.w    quit
  1040.  
  1041. menu_buttons_x:    moveq.l    #0,d0
  1042.         move.l    d1,a0
  1043.         move.w    gg_GadgetID(a0),d0        ;d0 = gadget id.
  1044.         lea    menu_jump_tbl,a0
  1045.         jmp    ([a0,d0.l*4])
  1046.  
  1047. menu_menu_its:    cmp.w    #$ffff,d2            ;no selections?
  1048.         beq.w    get_message            ;yes. exit this.
  1049.  
  1050.         move.b    d2,d0
  1051.         lsr.w    #5,d2
  1052.         and.w    #%111111,d2
  1053.  
  1054.         and.b    #%11,d0                ;check out the menu number.
  1055.         beq.s    menu_go_I
  1056.         cmp.b    #1,d0
  1057.         beq.s    menu_go_II
  1058.         bra.w    get_message
  1059.  
  1060. menu_keys_x:    cmp.b    #"l",d2
  1061.         beq.w    menu_rom_load
  1062.         cmp.b    #"r",d2
  1063.         beq.w    menu_rom_run
  1064.         cmp.b    #"e",d2
  1065.         beq.w    menu_rom_reset
  1066.         cmp.b    #"i",d2
  1067.         beq.w    menu_rom_info
  1068.  
  1069.         cmp.b    #"o",d2
  1070.         beq.w    menu_gbs_load
  1071.         cmp.b    #"a",d2
  1072.         beq.w    menu_gbs_save
  1073.         cmp.b    #"b",d2
  1074.         beq.w    menu_misc_about
  1075.  
  1076.         cmp.b    #"g",d2
  1077.         beq.w    menu_edit_gfx
  1078.         cmp.b    #"s",d2
  1079.         beq.w    menu_edit_sfx
  1080.         cmp.b    #"p",d2
  1081.         beq.w    menu_edit_prefs
  1082.         cmp.b    #"m",d2
  1083.         beq.w    menu_edit_misc
  1084.  
  1085.         bra.w    get_message
  1086.  
  1087. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1088. ;        do things for menu items
  1089. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1090.  
  1091. menu_go_I:    lsl.w    #5,d2                ;position is 32.B aligned.
  1092.         move.l    prefs_file,a0
  1093.         add.l    #560,a0
  1094.         bra.s    menu_go_go
  1095.  
  1096. menu_go_II:    lsl.w    #5,d2                ;position is 32.B aligned.
  1097.         move.l    menu_favo_nf,a0
  1098.  
  1099. menu_go_go:    add.l    d2,a0                ;activated item selected.
  1100.         move.l    name_ptr,a1            ;output.
  1101.         tst.l    (a0)
  1102.         beq.w    get_message            ;an empty item.
  1103.         move.l    (a0)+,(a1)+
  1104.         move.l    (a0)+,(a1)+
  1105.         move.l    (a0)+,(a1)+
  1106.         move.l    (a0)+,(a1)+
  1107.         move.l    (a0)+,(a1)+
  1108.         move.l    (a0)+,(a1)+
  1109.         move.l    (a0)+,(a1)+
  1110.         move.l    (a0),(a1)            ;new name copied.
  1111.         move.b    #1,load_menu_tag        ;an old name load.
  1112.         bsr.w    load_load_cart            ;load a rom image.
  1113.         clr.b    load_menu_tag
  1114.         bra.w    jump_g_load_aft            ;the normal procedures.
  1115.  
  1116. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1117. ;        message from the wzonka game window
  1118. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1119.  
  1120. wzonka_message:    move.l    d0,a1
  1121.         move.l    im_Class(a1),d0
  1122.         move.l    im_IAddress(a1),d1        ;address of a gadget.
  1123.  
  1124.         move.l    d0,-(SP)
  1125.         jsr    ReplyMsg(a6)            ;reply to it.
  1126.         move.l    (SP)+,d0
  1127.  
  1128.         cmp.l    #IDCMP_NEWSIZE,d0
  1129.         bne.w    get_message
  1130.  
  1131. wzonka_message_new_window_size:
  1132.         tst.b    scaling_status
  1133.         beq.w    get_message
  1134.  
  1135.         moveq.l    #0,d2
  1136.         move.l    wzonka_ptr,a5
  1137.         move.w    wd_Width(a5),d2
  1138.         move.l    d2,d3
  1139.         sub.l    window_bars_width,d2
  1140.         sub.l    #window_right_bar_x,d2
  1141.  
  1142.         movem.l    d2/d3,-(SP)
  1143.         bsr.w    close_and_free_window
  1144.         movem.l    (SP)+,d2/d3
  1145.  
  1146.         and.l    #%1111,d2
  1147.         and.l    #$0000ffff,d3
  1148.         sub.l    d2,d3
  1149.         move.w    d3,wzonka_window_x
  1150.  
  1151.         bsr.w    allocate_window
  1152.         bra.w    get_message
  1153.  
  1154. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1155. ;        message from the function window
  1156. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1157.  
  1158. function_message:
  1159.         move.l    exec_base,a6
  1160.         move.l    d0,a1
  1161.         move.l    im_Class(a1),d0
  1162.  
  1163.         cmp.l    #IDCMP_CLOSEWINDOW,d0
  1164.         beq.s    function_quit
  1165.  
  1166.         move.l    im_IAddress(a1),d1        ;address of a gadget.
  1167.  
  1168.         movem.l    d0/d1,-(SP)
  1169.         jsr    ReplyMsg(a6)            ;reply to it.
  1170.         movem.l    (SP)+,d0/d1
  1171.  
  1172.         cmp.l    #IDCMP_GADGETUP,d0
  1173.         beq.s    get_function_message
  1174.         cmp.l    #IDCMP_GADGETDOWN,d0
  1175.         beq.s    get_function_message
  1176.         cmp.l    #IDCMP_MOUSEBUTTONS,d0
  1177.         beq.s    get_function_message
  1178.         cmp.l    #IDCMP_MOUSEMOVE,d0
  1179.         beq.s    get_function_message
  1180.         bra.w    get_message
  1181.  
  1182. get_function_message:
  1183.         moveq.l    #0,d0
  1184.         move.l    d1,a0
  1185.         move.w    gg_GadgetID(a0),d0        ;d0 = gadget id.
  1186.         move.l    function_jmp,a0
  1187.         jmp    ([a0,d0.l*4])
  1188.  
  1189.         cmp.l    #IDCMP_CLOSEWINDOW,d0
  1190.         beq.s    function_quit
  1191.  
  1192. function_quit:    jsr    ReplyMsg(a6)
  1193.  
  1194.         bsr.w    gadgets_rmv
  1195.  
  1196.         move.l    function_ptr,a5
  1197.         lea    function_window,a4
  1198.         move.w    wd_LeftEdge(a5),nw_LeftEdge(a4)
  1199.         move.w    wd_TopEdge(a5),nw_TopEdge(a4)
  1200.  
  1201.         lea    function_ptr,a5
  1202.         bsr.w    close_window
  1203.  
  1204.         clr.l    function_status
  1205.  
  1206.         bra.w    get_message
  1207.  
  1208. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1209. ;        function message from window gadgets only
  1210. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1211.  
  1212. function_message_exec:
  1213.         move.l    d0,a1
  1214.         move.l    im_Class(a1),d0
  1215.  
  1216.         cmp.l    #IDCMP_CLOSEWINDOW,d0
  1217.         beq.s    function_quit
  1218.  
  1219.         jsr    ReplyMsg(a6)
  1220.  
  1221.         bra.w    get_message
  1222.  
  1223. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1224. ;        jump table
  1225. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1226.  
  1227. menu_jump_tbl:    dc.l    menu_rom_load
  1228.         dc.l    menu_rom_run
  1229.         dc.l    menu_rom_info
  1230.  
  1231.         dc.l    menu_gbs_load
  1232.         dc.l    menu_gbs_save
  1233.         dc.l    menu_misc_about
  1234.  
  1235.         dc.l    menu_edit_gfx
  1236.         dc.l    menu_edit_sfx
  1237.         dc.l    menu_edit_prefs
  1238.         dc.l    menu_edit_misc
  1239.  
  1240.         dc.l    menu_rom_reset
  1241.  
  1242. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1243. ;        allocate bit map (tmp)
  1244. ;        INPUT:
  1245. ;        a4    = another bit map.
  1246. ;        a5    = place for pointer.
  1247. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1248.  
  1249. alloc_bit_map:    move.l    #304,d0
  1250. alloc_bit_map_other:
  1251.         moveq.l    #1,d1
  1252.         moveq.l    #0,d2
  1253.         move.b    bm_Depth(a4),d2
  1254.         moveq.l    #0,d3
  1255.         sub.l    a0,a0
  1256.         move.l    graphics_base,a6
  1257.         jsr    AllocBitMap(a6)
  1258.         move.l    d0,(a5)
  1259.         rts
  1260.  
  1261. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1262. ;        init the given bitmap
  1263. ;        INPUT:
  1264. ;        d0    = z.
  1265. ;        d1    = x.
  1266. ;        d2    = y.
  1267. ;        a0    = attributes.
  1268. ;        a1    = planes.
  1269. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1270.  
  1271. init_bit_map_function:
  1272.         move.l    #function_x_bm,d1
  1273.         move.l    #function_y_bm,d2
  1274.  
  1275. init_bit_map:    lea    bm_Planes(a0),a2
  1276.         move.l    d1,d3
  1277.         lsr.w    #3,d3
  1278.         mulu.w    d2,d3                ;d3 = x/8*y.
  1279.         move.w    d0,d7
  1280.         subq.w    #1,d7
  1281. init_bit_map_pt:move.l    a1,(a2)+
  1282.         add.l    d3,a1
  1283.         dbra    d7,init_bit_map_pt
  1284.  
  1285.         move.l    graphics_base,a6
  1286.         jsr    InitBitMap(a6)
  1287.         rts
  1288.  
  1289. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1290. ;        create gadgets
  1291. ;        INPUT:
  1292. ;        a4    = gadget list
  1293. ;        a5    = the first gadget
  1294. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1295.  
  1296. gadget_crt:    move.l    gad_tools_base,a6
  1297.  
  1298. gadget_crt_s:    move.l    univ_gadget,a1
  1299.         move.w    (a4)+,gng_LeftEdge(a1)        ;x.
  1300.         beq.w    gadget_crt_x            ;end of gadgets.
  1301.         move.w    (a4)+,gng_TopEdge(a1)        ;y.
  1302.         move.l    (a4)+,gng_Flags(a1)        ;flags.
  1303.         move.l    (a4)+,gng_GadgetText(a1)    ;text.
  1304.         move.w    (a4)+,gng_GadgetID(a1)        ;id number.
  1305.         move.l    #font_attr,gng_TextAttr(a1)
  1306.         move.l    visual_info,gng_VisualInfo(a1)
  1307.  
  1308.         move.l    (a5),a0
  1309.         move.w    (a4)+,d1
  1310.         beq.s    gadget_crt_btn            ;no tags! (button_kind).
  1311.         cmp.b    #1,d1
  1312.         beq.s    gadget_crt_mx            ;mx_kind!
  1313.         cmp.b    #2,d1
  1314.         beq.s    gadget_crt_str            ;string_kind!
  1315.         cmp.b    #3,d1
  1316.         beq.w    gadget_crt_lw            ;listview_kind!
  1317.         cmp.b    #4,d1
  1318.         beq.w    gadget_crt_sld            ;slider_kind!
  1319.         cmp.b    #5,d1
  1320.         beq.w    gadget_crt_chb            ;checkbox kind!
  1321.  
  1322. gadget_crt_mx:    move.w    #17,gng_Width(a1)        ;dx.
  1323.         move.w    #9,gng_Height(a1)        ;dy.
  1324.         move.l    (a4)+,a2
  1325.         move.l    (a4)+,4(a2)            ;labels list.
  1326.         move.l    (a4)+,a5
  1327.         moveq.l    #0,d0
  1328.         move.b    (a5),d0
  1329.         move.l    d0,12(a2)            ;active number.
  1330.         move.l    #MX_KIND,d0            ;gadget type.
  1331.         jsr    CreateGadgetA(a6)
  1332.  
  1333.         move.l    (a4)+,a5
  1334.         move.l    d0,(a5)
  1335.         beq.w    gadget_crt_err
  1336.         bra.w    gadget_crt_s
  1337.  
  1338. gadget_crt_btn:    move.w    (a4)+,gng_Width(a1)        ;dx.
  1339.         move.w    (a4)+,gng_Height(a1)        ;dy.
  1340.         lea    button_gadget_underscore_tag,a2 ;no tags!
  1341.         move.l    #BUTTON_KIND,d0
  1342.         jsr    CreateGadgetA(a6)
  1343.  
  1344.         move.l    (a4)+,a5
  1345.         move.l    d0,(a5)
  1346.         beq.w    gadget_crt_err
  1347.         bra.w    gadget_crt_s
  1348.  
  1349. gadget_crt_str:    move.w    (a4)+,gng_Width(a1)        ;dx.
  1350.         move.w    (a4)+,gng_Height(a1)        ;dy.
  1351.         move.l    (a4)+,a2
  1352.         move.l    (a4)+,a5
  1353.         move.l    (a5),4(a2)
  1354.         move.l    #STRING_KIND,d0
  1355.         jsr    CreateGadgetA(a6)
  1356.  
  1357.         move.l    (a4)+,a5
  1358.         move.l    d0,(a5)
  1359.         beq.w    gadget_crt_err
  1360.         bra.w    gadget_crt_s
  1361.  
  1362. gadget_crt_lw:    move.w    (a4)+,gng_Width(a1)        ;dx.
  1363.         move.w    (a4)+,gng_Height(a1)        ;dy.
  1364.         move.l    (a4)+,a2
  1365.         move.l    (a4)+,a5
  1366.         moveq.l    #0,d0
  1367.         move.b    (a5),d0
  1368.         move.l    d0,12(a2)
  1369.         move.l    d0,20(a2)
  1370.         move.l    #LISTVIEW_KIND,d0
  1371.         jsr    CreateGadgetA(a6)
  1372.  
  1373.         move.l    (a4)+,a5
  1374.         move.l    d0,(a5)
  1375.         beq.s    gadget_crt_err
  1376.         bra.w    gadget_crt_s
  1377.  
  1378. gadget_crt_sld:    move.w    (a4)+,gng_Width(a1)        ;dx.
  1379.         move.w    (a4)+,gng_Height(a1)        ;dy.
  1380.         move.l    (a4)+,a2
  1381.         move.l    (a4)+,12(a2)
  1382.         move.l    (a4)+,a5
  1383.         moveq.l    #0,d0
  1384.         move.b    (a5),d0
  1385.         move.l    d0,4(a2)
  1386.         move.l    #SLIDER_KIND,d0            ;gadget type.
  1387.         jsr    CreateGadgetA(a6)
  1388.  
  1389.         move.l    (a4)+,a5
  1390.         move.l    d0,(a5)
  1391.         beq.s    gadget_crt_err
  1392.         bra.w    gadget_crt_s
  1393.  
  1394. gadget_crt_chb:    move.l    (a4)+,a2
  1395.         moveq.l    #0,d0
  1396.         move.l    (a4)+,a5
  1397.         move.b    (a5),d0
  1398.         move.l    d0,4(a2)
  1399.         move.l    #CHECKBOX_KIND,d0
  1400.         jsr    CreateGadgetA(a6)
  1401.  
  1402.         move.l    (a4)+,a5
  1403.         move.l    d0,(a5)
  1404.         beq.w    gadget_crt_err
  1405.         bra.w    gadget_crt_s
  1406.  
  1407. gadget_crt_x:    moveq.l    #0,d0
  1408.         rts
  1409. gadget_crt_err:    moveq.l    #1,d0
  1410.         rts
  1411.  
  1412. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1413. ;        menu rom reset
  1414. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1415.  
  1416. menu_rom_reset:    tst.l    cartridge
  1417.         beq.w    get_message
  1418.  
  1419.         bsr.w    save_battery_ram
  1420.         move.b    #1,load_or_reset
  1421.         bsr.w    load_ok_ok
  1422.         bra.s    jump_g_load_aft
  1423.  
  1424. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1425. ;        menu rom load
  1426. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1427.  
  1428. menu_rom_load:    bsr.w    load_rom
  1429.  
  1430. jump_g_load_aft:tst.l    d0                ;any errors?
  1431.         beq.w    menu_rom_load_okay
  1432.         cmp.b    #1,d0
  1433.         beq.w    get_message            ;not selected!
  1434.  
  1435.         move.b    #1,cartridge_status        ;invalid ROM!
  1436.         bra.w    get_message
  1437.  
  1438. menu_rom_load_okay:
  1439.         clr.l    four_ram_banks_from_gbs        ;set by GBS loading when
  1440.                             ;appropriate.
  1441.         clr.l    ram_bank_no
  1442.  
  1443.         bsr.w    gb_memory_at_start        ;init some values.
  1444.  
  1445.         move.l    memory_banks,a0            ;randomize battery RAM.
  1446.         move.w    #131072/4/4-1,d0
  1447.         move.l    #$51347394,d1
  1448. randomize_ram_banks:
  1449.         move.l    d1,(a0)+
  1450.         add.l    #$01020103,d1
  1451.         move.l    d1,(a0)+
  1452.         add.l    #$02010301,d1
  1453.         move.l    d1,(a0)+
  1454.         add.l    #$01020103,d1
  1455.         move.l    d1,(a0)+
  1456.         add.l    #$02010301,d1
  1457.         dbra    d0,randomize_ram_banks
  1458.  
  1459.         bsr.w    load_battery_ram
  1460.         bsr.w    load_prefs            ;load rom image prefs.
  1461.         move.b    #1,new_load            ;sign of a new load!
  1462.         bsr.w    do_info
  1463.         bsr.w    get_gg
  1464.  
  1465.         tst.b    cartridge_status
  1466.         beq.s    cartridge_is_ok
  1467.  
  1468.         lea    status_corrupted_rom_txt,a5
  1469.         bsr.w    print_status_middle
  1470.  
  1471.         bra.w    get_message
  1472.  
  1473. cartridge_is_ok:tst.b    load_or_reset
  1474.         bne.s    cartridge_reset_is_ok
  1475.  
  1476.         lea    status_rom_loaded_txt,a5
  1477.         bsr.w    print_status_middle
  1478.         bra.w    get_message
  1479.  
  1480. cartridge_reset_is_ok:
  1481.         lea    status_rom_reset_txt,a5
  1482.         bsr.w    print_status_middle
  1483.         bra.w    get_message
  1484.  
  1485. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1486. ;        save battery ram
  1487. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1488.  
  1489. save_battery_ram:
  1490.         bsr.w    battery_existence
  1491.         tst.l    d0
  1492.         bne.s    save_battery_ram_exit        ;no battery.
  1493.  
  1494.         tst.b    battery_status
  1495.         bne.s    save_battery_ram_exit
  1496.         tst.l    cartridge
  1497.         beq.s    save_battery_ram_exit
  1498.  
  1499.         bsr.w    copy_cartridge_name_to_file_name
  1500.  
  1501.         move.b    battery_xpk_status,d6        ;xpk status.
  1502.         move.l    cartridge,a0
  1503.         moveq.l    #0,d1
  1504.         move.b    $149(a0),d1
  1505.         lea    ram_size_list,a1
  1506.         and.b    #%111,d1
  1507.         move.l    (a1,d1.l*4),d7
  1508.  
  1509.         cmp.l    #8192,d7
  1510.         beq.s    save_one_bank
  1511.  
  1512. save_four_banks_or_more:
  1513.         move.l    memory_banks,a3
  1514.         move.l    a3,a5
  1515.         move.l    gb_memory,a4
  1516.         add.l    #$A000,a4
  1517.         move.l    ram_bank_no,d0            ;the active bank.
  1518.         lsl.l    #8,d0
  1519.         lsl.l    #5,d0                ;8kb.
  1520.         add.l    d0,a3
  1521.         move.w    #8192/4/4-1,d0
  1522. save_active_bank:
  1523.         move.l    (a4)+,(a3)+
  1524.         move.l    (a4)+,(a3)+
  1525.         move.l    (a4)+,(a3)+
  1526.         move.l    (a4)+,(a3)+
  1527.         dbra    d0,save_active_bank
  1528.         bra.s    save_the_banks
  1529.  
  1530. save_one_bank:    move.l    gb_memory,a5
  1531.         add.l    #$A000,a5
  1532.  
  1533. save_the_banks:    bsr.w    save_file
  1534.  
  1535. save_battery_ram_exit:
  1536.         rts
  1537.  
  1538. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1539. ;        load battery ram
  1540. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1541.  
  1542. load_battery_ram:
  1543.         clr.b    battery_load            ;no battery loaded, yet.
  1544.  
  1545.         bsr.b    battery_existence
  1546.         tst.l    d0
  1547.         bne.s    load_battery_ram_exit        ;no battery.
  1548.  
  1549.         tst.b    battery_status
  1550.         bne.s    load_battery_ram_exit
  1551.         tst.l    cartridge
  1552.         beq.s    save_battery_ram_exit
  1553.  
  1554.         bsr.b    copy_cartridge_name_to_file_name
  1555.  
  1556.         move.l    memory_banks,a5
  1557.         move.l    cartridge,a0
  1558.         moveq.l    #0,d1
  1559.         move.b    $149(a0),d1
  1560.         lea    ram_size_list,a1
  1561.         and.b    #%111,d1
  1562.         move.l    (a1,d1.l*4),d7
  1563.         bsr.w    load_file
  1564.         tst.l    d0
  1565.         bne.s    load_battery_ram_exit        ;error!
  1566.  
  1567. use_loaded_battery_ram:
  1568.         move.l    memory_banks,a0
  1569.         move.l    gb_memory,a1
  1570.         add.l    #$A000,a1
  1571.         move.w    #$2000/4/8-1,d0
  1572. copy_ram_banks:    move.l    (a0)+,(a1)+
  1573.         move.l    (a0)+,(a1)+
  1574.         move.l    (a0)+,(a1)+
  1575.         move.l    (a0)+,(a1)+
  1576.         move.l    (a0)+,(a1)+
  1577.         move.l    (a0)+,(a1)+
  1578.         move.l    (a0)+,(a1)+
  1579.         move.l    (a0)+,(a1)+
  1580.         dbra    d0,copy_ram_banks
  1581.  
  1582.         move.b    #1,battery_load            ;battery loaded!
  1583.  
  1584. load_battery_ram_exit:
  1585.         rts
  1586.  
  1587. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1588. ;        battery existence checker
  1589. ;        OUTPUT:
  1590. ;        d0    = status (0 = battery found / 1 = no battery).
  1591. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1592.  
  1593. battery_existence:
  1594.         move.l    cartridge,d0
  1595.         beq.s    battery_existence_error
  1596.         move.l    d0,a0
  1597.         move.b    $147(a0),d0
  1598.         cmp.b    #3,d0
  1599.         beq.s    battery_existence_exit
  1600.         cmp.b    #6,d0
  1601.         beq.s    battery_existence_exit
  1602.         cmp.b    #9,d0
  1603.         beq.s    battery_existence_exit
  1604.         cmp.b    #$10,d0
  1605.         beq.s    battery_existence_exit
  1606.         cmp.b    #$13,d0
  1607.         beq.s    battery_existence_exit
  1608.         cmp.b    #$1b,d0
  1609.         beq.s    battery_existence_exit
  1610.         cmp.b    #$ff,d0
  1611.         beq.s    battery_existence_exit
  1612.  
  1613. battery_existence_error:
  1614.         moveq.l    #1,d0                ;no battery.
  1615.         rts
  1616.  
  1617. battery_existence_exit:
  1618.         moveq.l    #0,d0                ;battery found.
  1619.         rts
  1620.  
  1621. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1622. ;        copy cartridge name to file name to be used by
  1623. ;        battery loader
  1624. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1625.  
  1626. copy_cartridge_name_to_file_name:
  1627.         move.l    prefs_str_4,prefs_str_ptr
  1628.         bsr.w    get_cartridge_path_and_name
  1629.         move.l    #".sav",(a0)+
  1630.         clr.b    (a0)
  1631.         rts
  1632.  
  1633. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1634. ;        get gg list
  1635. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1636.  
  1637. GG_ERROR    =0
  1638. GG_GG_BEGIN    =1
  1639. GG_GAME_BEGIN    =2
  1640. GG_NAME        =3
  1641. GG_CODE        =4
  1642. GG_DESC        =5
  1643. GG_GAME_END    =6
  1644. GG_GG_END    =7
  1645.  
  1646. get_gg:
  1647.         tst.l    gg_list
  1648.         beq.w    get_gg_list_exit_exit
  1649.         tst.l    gg_list_size
  1650.         beq.w    get_gg_list_exit_exit
  1651.         tst.l    cartridge
  1652.         beq.w    get_gg_list_exit_exit
  1653.  
  1654.                 moveq.l #1,d0
  1655.  
  1656.         bsr.w    free_gg_linked_list
  1657.  
  1658.         lea    gg_rom_name,a0
  1659.         bsr.w    copy_rom_name_to_a0
  1660.  
  1661.         move.l    gg_list,a1
  1662.         move.l    gg_list_size,d1
  1663.  
  1664.         addq.l    #1,a1
  1665.         subq.l    #1,d1
  1666.         beq.w    get_gg_list_exit
  1667.  
  1668.         bsr.w    get_gg_next_tag
  1669.         cmp.b    #GG_ERROR,d0
  1670.         beq.w    get_gg_list_exit
  1671.         cmp.b    #GG_GG_BEGIN,d0
  1672.         bne.w    get_gg_list_exit
  1673.  
  1674. get_gg_begin_loop:
  1675.         bsr.w    get_gg_next_tag
  1676.         cmp.b    #GG_GG_END,d0
  1677.         beq.w    get_gg_list_exit
  1678.         cmp.b    #GG_ERROR,d0
  1679.         beq.w    get_gg_list_exit
  1680.         cmp.b    #GG_GAME_BEGIN,d0
  1681.         beq.s    get_gg_name_loop
  1682.         bra.s    get_gg_begin_loop
  1683.  
  1684. get_gg_name_loop:
  1685.         bsr.w    get_gg_next_tag
  1686.         cmp.b    #GG_GG_END,d0
  1687.         beq.w    get_gg_list_exit
  1688.         cmp.b    #GG_ERROR,d0
  1689.         beq.w    get_gg_list_exit
  1690.         cmp.b    #GG_NAME,d0
  1691.         beq.s    get_gg_cmp_name
  1692.         bra.s    get_gg_name_loop
  1693.  
  1694. get_gg_cmp_name:lea    gg_rom_name,a0
  1695.         addq.l    #1,a1
  1696.         subq.l    #1,d1
  1697.         beq.w    get_gg_list_exit
  1698.         moveq.l    #16-1,d0
  1699.  
  1700. get_gg_cmp_name_loop:
  1701.         move.b    (a0)+,d7
  1702.         subq.l    #1,d1
  1703.         beq.w    get_gg_list_exit
  1704.         cmp.b    (a1)+,d7
  1705.         bne.s    get_gg_begin_loop
  1706.         dbra    d0,get_gg_cmp_name_loop
  1707.  
  1708. get_gg_name_size:
  1709.         bsr.w    get_gg_next_tag
  1710.         cmp.b    #GG_GG_END,d0
  1711.         beq.w    get_gg_list_exit
  1712.         cmp.b    #GG_ERROR,d0
  1713.         beq.w    get_gg_list_exit
  1714.         cmp.b    #GG_GAME_END,d0
  1715.         beq.s    get_gg_list_exit
  1716.         cmp.b    #GG_DESC,d0
  1717.         bne.s    get_gg_list_exit
  1718.  
  1719.         moveq.l    #0,d4
  1720.         move.l    a1,a0
  1721.         move.l    d1,d5
  1722.  
  1723. get_gg_name_size_loop:
  1724.         move.b    (a0)+,d7
  1725.         beq.s    get_gg_list_exit
  1726.         cmp.b    #$A,d7
  1727.         beq.s    get_gg_name_size_computed
  1728.         addq.l    #1,d4
  1729.         subq.l    #1,d5
  1730.         beq.s    get_gg_list_exit
  1731.         bra.s    get_gg_name_size_loop
  1732.  
  1733. get_gg_name_size_computed:
  1734.         tst.l    d4
  1735.         beq.s    get_gg_list_exit
  1736.  
  1737.         move.l    d4,-(SP)
  1738.         addq.l    #1,d4
  1739.         bsr.w    allocate_gg_linked_list_shell
  1740.         move.l    (SP)+,d4
  1741.         tst.l    d7
  1742.         beq.s    get_gg_list_exit
  1743.  
  1744.         move.l    d7,a0
  1745.         move.l    8(a0),a0
  1746.         move.l    a1,a3
  1747. get_gg_copy_name:
  1748.         move.b    (a3)+,(a0)+
  1749.         subq.l    #1,d4
  1750.         bne.s    get_gg_copy_name
  1751.         clr.b    (a0)
  1752.  
  1753.         move.l    d7,-(SP)
  1754.         bsr.w    get_gg_next_tag
  1755.         move.l    (SP)+,a0
  1756.         cmp.b    #GG_GG_END,d0
  1757.         beq.s    get_gg_list_exit
  1758.         cmp.b    #GG_ERROR,d0
  1759.         beq.s    get_gg_list_exit
  1760.         cmp.b    #GG_GAME_END,d0
  1761.         beq.s    get_gg_list_exit
  1762.         cmp.b    #GG_CODE,d0
  1763.         bne.s    get_gg_list_exit
  1764.  
  1765.         moveq.l    #3+1+3+1+3-1,d0
  1766.         move.l    d1,d4
  1767.         move.l    a1,a3
  1768.         add.l    #12,a0
  1769. get_gg_copy_code:
  1770.         move.b    (a3)+,(a0)+
  1771.         subq.l    #1,d4
  1772.         beq.s    get_gg_list_exit
  1773.         dbra    d0,get_gg_copy_code
  1774.  
  1775.         bra.w    get_gg_name_size        ;next name.
  1776.  
  1777. get_gg_list_exit:
  1778.         move.l    gg_linked_list,d0
  1779.         beq.s    get_gg_list_exit_exit
  1780.         move.l    d0,a1
  1781.         move.l    4(a1),d0
  1782.         beq.s    get_gg_list_exit_exit
  1783.         move.l    d0,a1
  1784.  
  1785.         move.l    gg_linked_list_last_item,d0
  1786.         beq.s    get_gg_list_exit_exit
  1787.         move.l    d0,a2
  1788.         move.l    4(a2),d0
  1789.         beq.s    get_gg_list_exit_exit
  1790.         move.l    d0,a2
  1791.  
  1792.         move.l    gg_label_list,a6
  1793.         move.b    #1,gg_code_status
  1794.  
  1795.         move.l    a1,LH_HEAD(a6)
  1796.         move.l    a6,LN_PRED(a1)
  1797.  
  1798.         move.l    a2,LH_TAILPRED(a6)
  1799.         lea    LH_TAIL(a6),a5
  1800.         move.l    a5,LN_SUCC(a2)
  1801.  
  1802.         bra.s    get_gg_install_new_list
  1803.  
  1804. get_gg_list_exit_exit:
  1805.         move.l    gg_dummy_item,a1
  1806.         move.l    gg_label_list,a6
  1807.  
  1808.         move.l    a1,LH_HEAD(a6)
  1809.         move.l    a6,LN_PRED(a1)
  1810.  
  1811.         move.l    #gg_dummy_item_txt,d0
  1812.         move.b    #2,gg_code_status
  1813.  
  1814. get_gg_list_exit_exit_reg:
  1815.         move.l    d0,LN_NAME(a1)
  1816.         move.l    a1,LH_TAILPRED(a6)
  1817.         lea    LH_TAIL(a6),a5
  1818.         move.l    a5,LN_SUCC(a1)
  1819.  
  1820. get_gg_install_new_list:
  1821.         cmp.l    #"MISC",function_status
  1822.         bne.s    get_gg_x
  1823.  
  1824.         move.l    misc_b_code_list,d0
  1825.         beq.s    get_gg_x
  1826.         move.l    d0,a0
  1827.         move.l    gad_tools_base,a6
  1828.         move.l    function_ptr,a1
  1829.         sub.l    a2,a2
  1830.         lea    misc_b_code_list_change_tags,a3
  1831.         move.l    gg_label_list,4(a3)
  1832.         jsr    GT_SetGadgetAttrsA(a6)
  1833.  
  1834. get_gg_x:    rts
  1835.  
  1836. get_gg_next_tag:move.b    -1(a1),d7
  1837.         lsl.w    #8,d7
  1838.         move.b    (a1)+,d7
  1839.  
  1840.         subq.l    #1,d1
  1841.         beq.w    get_gg_next_tag_error
  1842.         cmp.w    #$0A23,d7            ;$A, '#'.
  1843.         beq.s    get_gg_next_tag_tag
  1844.         bra.s    get_gg_next_tag
  1845.  
  1846. get_gg_next_tag_tag:
  1847.         cmp.l    #'GG_B',(a1)
  1848.         bne.s    get_gg_next_tag_tag_1
  1849.         cmp.l    #'EGIN',4(a1)
  1850.         bne.s    get_gg_next_tag_tag_1
  1851.         move.b    #GG_GG_BEGIN,d0
  1852.         bra.s    get_gg_next_tag_tag_ok
  1853.  
  1854. get_gg_next_tag_tag_1:
  1855.         cmp.l    #'GAME',(a1)
  1856.         bne.s    get_gg_next_tag_tag_2
  1857.         cmp.l    #'_BEG',4(a1)
  1858.         bne.s    get_gg_next_tag_tag_2
  1859.         cmp.w    #'IN',8(a1)
  1860.         bne.s    get_gg_next_tag_tag_2
  1861.         move.b    #GG_GAME_BEGIN,d0
  1862.         bra.s    get_gg_next_tag_tag_ok
  1863.  
  1864. get_gg_next_tag_tag_2:
  1865.         cmp.l    #'NAME',(a1)
  1866.         bne.s    get_gg_next_tag_tag_3
  1867.         move.b    #GG_NAME,d0
  1868.         bra.s    get_gg_next_tag_tag_ok
  1869.  
  1870. get_gg_next_tag_tag_3:
  1871.         cmp.l    #'CODE',(a1)
  1872.         bne.s    get_gg_next_tag_tag_4
  1873.         move.b    #GG_CODE,d0
  1874.         bra.s    get_gg_next_tag_tag_ok
  1875.  
  1876. get_gg_next_tag_tag_4:
  1877.         cmp.l    #'DESC',(a1)
  1878.         bne.s    get_gg_next_tag_tag_5
  1879.         move.b    #GG_DESC,d0
  1880.         bra.s    get_gg_next_tag_tag_ok
  1881.  
  1882. get_gg_next_tag_tag_5:
  1883.         cmp.l    #'GAME',(a1)
  1884.         bne.s    get_gg_next_tag_tag_6
  1885.         cmp.l    #'_END',4(a1)
  1886.         bne.s    get_gg_next_tag_tag_6
  1887.         move.b    #GG_GAME_END,d0
  1888.         bra.s    get_gg_next_tag_tag_ok
  1889.  
  1890. get_gg_next_tag_tag_6:
  1891.         cmp.l    #'GG_E',(a1)
  1892.         bne.s    get_gg_next_tag_tag_7
  1893.         cmp.w    #'ND',4(a1)
  1894.         bne.s    get_gg_next_tag_tag_7
  1895.         move.b    #GG_GG_END,d0
  1896.         bra.s    get_gg_next_tag_tag_ok
  1897.  
  1898. get_gg_next_tag_tag_7:
  1899.         bra.w    get_gg_next_tag
  1900.  
  1901. get_gg_next_tag_tag_ok:
  1902.         move.b    (a1)+,d7
  1903.         subq.l    #1,d1
  1904.         beq.s    get_gg_next_tag_error
  1905.         cmp.b    #$A,d7
  1906.         bne.s    get_gg_next_tag_tag_ok
  1907.         rts
  1908.  
  1909. get_gg_next_tag_error:
  1910.         move.b    #GG_ERROR,d0
  1911.         rts
  1912.  
  1913. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1914. ;        free gg linked list
  1915. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1916.  
  1917. ;        .L    = pointer to next item.
  1918. ;        .L    = pointer to list item.
  1919. ;        .L    = pointer to text.
  1920. ;        .L*3    = game genie code.
  1921.  
  1922. free_gg_linked_list:
  1923.         cmp.l    #"MISC",function_status
  1924.         bne.s    free_gg_x
  1925.  
  1926.         move.l    misc_b_code_list,d0
  1927.         beq.s    free_gg_x
  1928.         move.l    d0,a0
  1929.         move.l    gad_tools_base,a6
  1930.         move.l    function_ptr,a1
  1931.         sub.l    a2,a2
  1932.         lea    misc_b_code_list_change_tags,a3
  1933.         clr.l    4(a3)                ;detach!
  1934.         jsr    GT_SetGadgetAttrsA(a6)
  1935.  
  1936. free_gg_x:    move.l    gg_label_list,d0
  1937.         beq.s    get_gg_free_old_linked_list_start
  1938.         move.l    d0,a6
  1939.         clr.l    LH_HEAD(a6)
  1940.         clr.l    LH_TAILPRED(a6)
  1941.  
  1942. get_gg_free_old_linked_list_start:
  1943.         move.l    gg_linked_list,d6
  1944.         move.l    exec_base,a6
  1945.  
  1946. get_gg_free_old_linked_list:
  1947.         tst.l    d6
  1948.         beq.s    get_gg_linked_list_freed
  1949.  
  1950.         move.l    d6,a1
  1951.         move.l    (a1),d6
  1952.         move.l    4(a1),d5
  1953.         move.l    8(a1),d4
  1954.         jsr    FreeVec(a6)
  1955.  
  1956.         tst.l    d5
  1957.         beq.s    get_gg_free_1
  1958.         move.l    d5,a1
  1959.         jsr    FreeVec(a6)
  1960.  
  1961. get_gg_free_1:    tst.l    d4
  1962.         beq.s    get_gg_free_2
  1963.         move.l    d4,a1
  1964.         jsr    FreeVec(a6)
  1965.  
  1966. get_gg_free_2:    bra.s    get_gg_free_old_linked_list
  1967.  
  1968. get_gg_linked_list_freed:
  1969.         clr.l    gg_linked_list
  1970.         clr.l    gg_linked_list_last_item
  1971.         rts
  1972.  
  1973. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1974. ;        allocate a new shell to gg linked list
  1975. ;        INPUT:
  1976. ;        d4    = text size.
  1977. ;        OUTPUT:
  1978. ;        d7    = allocated shell.
  1979. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1980.  
  1981. ;        .L    = pointer to next item.
  1982. ;        .L    = pointer to list item.
  1983. ;        .L    = pointer to text.
  1984. ;        .L*3    = game genie code.
  1985.  
  1986. allocate_gg_linked_list_shell:
  1987.         movem.l    d0-d6/a0-a6,-(SP)
  1988.  
  1989.         move.l    exec_base,a6
  1990.         moveq.l    #3*4+3*4,d0
  1991.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  1992.         jsr    AllocVec(a6)
  1993.         tst.l    d0
  1994.         beq.w    allocate_gg_linked_list_shell_error
  1995.  
  1996.         move.l    d0,a5
  1997.  
  1998.         tst.l    gg_linked_list
  1999.         bne.s    allocate_gg_linked_list_another
  2000.  
  2001.         move.l    d0,gg_linked_list
  2002.         moveq.l    #0,d7
  2003.         bra.s    allocate_gg_linked_list_continue
  2004.  
  2005. allocate_gg_linked_list_another:
  2006.         move.l    gg_linked_list_last_item,a0
  2007.         move.l    d0,(a0)
  2008.         move.l    4(a0),d7
  2009.  
  2010. allocate_gg_linked_list_continue:
  2011.         move.l    a5,gg_linked_list_last_item
  2012.         clr.l    (a5)
  2013.         clr.l    4(a5)
  2014.         clr.l    8(a5)
  2015.  
  2016.         move.l    #LN_SIZE,d0
  2017.         addq.w    #2,d0
  2018.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  2019.         jsr    AllocVec(a6)
  2020.         tst.l    d0
  2021.         beq.s    allocate_gg_linked_list_shell_error
  2022.  
  2023.         move.l    d0,4(a5)
  2024.         move.l    d0,a4
  2025.  
  2026.         tst.l    d7
  2027.         beq.s    allocate_gg_linked_list_no_succ
  2028.         move.l    d7,a0
  2029.         move.l    d0,LN_SUCC(a0)
  2030.  
  2031. allocate_gg_linked_list_no_succ:
  2032.         move.l    d4,d0
  2033.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  2034.         jsr    AllocVec(a6)
  2035.         tst.l    d0
  2036.         beq.s    allocate_gg_linked_list_shell_error
  2037.  
  2038.         move.l    d0,8(a5)
  2039.         move.l    d0,LN_NAME(a4)
  2040.  
  2041.         tst.l    d7
  2042.         beq.s    allocate_gg_linked_list_no_pred
  2043.         move.l    d7,LN_PRED(a4)
  2044.  
  2045. allocate_gg_linked_list_no_pred:
  2046.         movem.l    (SP)+,d0-d6/a0-a6
  2047.         move.l    gg_linked_list_last_item,d7
  2048.         rts
  2049.  
  2050. allocate_gg_linked_list_shell_error:
  2051.         movem.l    (SP)+,d0-d6/a0-a6
  2052.         moveq.l    #0,d7
  2053.         rts
  2054.  
  2055. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2056. ;        set & clear window pointer
  2057. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2058.  
  2059. set_window_pointer:
  2060.         tst.l    (a0)
  2061.         beq.s    set_window_pointer_exit
  2062.  
  2063.         move.l    intuition_base,a6
  2064.         move.l    (a0),a0
  2065.         lea    pause_pointer_tags,a1
  2066.         jsr    SetWindowPointerA(a6)
  2067.  
  2068. set_window_pointer_exit:
  2069.         rts
  2070.  
  2071. clear_window_pointer:
  2072.         tst.l    (a0)
  2073.         beq.s    clear_window_pointer_exit
  2074.  
  2075.         move.l    intuition_base,a6
  2076.         move.l    (a0),a0
  2077.         jsr    ClearPointer(a6)
  2078.  
  2079. clear_window_pointer_exit:
  2080.         rts
  2081.  
  2082. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2083. ;        menu rom run
  2084. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2085.  
  2086. menu_rom_run:    tst.b    cartridge_status
  2087.         bne.w    get_message
  2088.  
  2089.         tst.l    cartridge
  2090.         beq.w    get_message
  2091.  
  2092.         lea    menu_ptr,a0
  2093.         bsr.b    set_window_pointer
  2094.         lea    function_ptr,a0
  2095.         bsr.b    set_window_pointer
  2096.         lea    wzonka_ptr,a0
  2097.         bsr.b    set_window_pointer
  2098.  
  2099.         tst.b    old_render
  2100.         bne.s    menu_rom_run_no_aga
  2101.         tst.b    aga_status
  2102.         beq.w    get_message            ;no aga available.
  2103.  
  2104. menu_rom_run_no_aga:
  2105.         lea    status_running_txt,a5
  2106.         bsr.w    print_status_middle
  2107.  
  2108.         tst.b    forbid_permit_status
  2109.         bne.s    no_forbid
  2110.  
  2111.         move.l    exec_base,a6
  2112.         jsr    Forbid(a6)
  2113.  
  2114. no_forbid:    
  2115.  
  2116. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2117. ;        test cybergraphics screen
  2118. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2119.  
  2120.         tst.l    cyber_base
  2121.         beq.s    no_cyber_graphics_screen
  2122.  
  2123.         tst.b    old_render
  2124.         beq.s    no_cyber_graphics_screen
  2125.         cmp.b    #1,old_render
  2126.         beq.s    test_screen_id
  2127.  
  2128. test_workbench_id:
  2129.         move.l    pub_screen_lock,a0
  2130.         bra.s    get_cyber_id
  2131.  
  2132. test_screen_id:    move.l    gb_screen_ptr,a0
  2133.  
  2134. get_cyber_id:    lea    sc_ViewPort(a0),a0
  2135.         move.l    graphics_base,a6
  2136.         jsr    GetVPModeID(a6)
  2137.  
  2138.         move.l    cyber_base,a6
  2139.         jsr    IsCyberModeID(a6)
  2140.         move.l    d0,output_cyber_status
  2141.  
  2142. no_cyber_graphics_screen:
  2143.         move.l    cartridge,a0
  2144.         bsr.w    compute_jmp_lst            ;create the mem jump table.
  2145.  
  2146.         bsr.w    turn_ahi_on            ;on with the music.
  2147.         bsr.w    do_pen_table
  2148.         bsr.w    screen_empty            ;empty the buffer.
  2149.         clr.b    output_bit            ;for frame skipping.
  2150.  
  2151.         moveq.l    #0,d1
  2152.         move.b    sfx_y_update,d1
  2153.         addq.b    #1,d1
  2154.         swap    d1
  2155.         divu.l    #60,d1
  2156.         move.l    d1,sfx_y_adder
  2157.         move.l    #$10000,sfx_y_actual_value    ;init the counter (y mode).
  2158.  
  2159.         cmp.b    #1,old_render            ;screen mode?
  2160.         bne.s    no_scr_front            ;nope.
  2161.  
  2162.         move.l    intuition_base,a6
  2163.         move.l    gb_screen_ptr,a0        ;the screen.
  2164.         jsr    ScreenToFront(a6)        ;bring it near.
  2165. no_scr_front:
  2166.  
  2167. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2168. ;        allocate controller resources
  2169. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2170.  
  2171.         lea    joy_item_list,a0
  2172.         moveq.l    #0,d0
  2173.         move.b    keystick,d0
  2174.         move.b    (a0,d0.l),d1            ;keyboard?
  2175.         beq.s    keyb_alloc
  2176.         cmp.b    #1,d1                ;cd³² pad?
  2177.         beq.s    cd32_alloc
  2178.         cmp.b    #2,d1                ;sega 4 button pad?
  2179.         beq.s    sega_4b_alloc
  2180.         cmp.b    #3,d1                ;sega 2 button pad?
  2181.         beq.s    sega_2b_alloc
  2182.         cmp.b    #4,d1                ;1b joystick?
  2183.         beq.s    joystick_alloc
  2184.         cmp.b    #5,d1                ;2b joystick?
  2185.         beq.s    joystick_alloc
  2186.  
  2187. cd32_alloc:    move.l    exec_base,a6
  2188.         lea    low_level_name,a1
  2189.         moveq.l    #0,d0
  2190.         jsr    OpenLibrary(a6)
  2191.         move.l    d0,low_level_base
  2192.         bra.s    control_a_done
  2193.  
  2194. sega_4b_alloc:    bsr.b    sega_alloc            ;sega routines
  2195.         bra.s    control_a_done            ;and nothing else.
  2196.  
  2197. sega_2b_alloc:    bsr.b    sega_alloc            ;sega routines
  2198.         bsr.b    keyb_init_yes            ;and the keyboard routines.
  2199.         bra.s    control_a_done
  2200.  
  2201. keyb_alloc:    bsr.b    keyb_init_yes
  2202.         bra.s    control_a_done
  2203.  
  2204. joystick_alloc:    bsr.b    keyb_init_yes
  2205.         bra.s    control_a_done
  2206.  
  2207. sega_alloc:    move.l    exec_base,a6
  2208.         lea    control_pad_name,a1
  2209.         moveq.l    #0,d0
  2210.         jsr    OpenLibrary(a6)
  2211.         move.l    d0,control_pad_base
  2212.         beq.s    no_cp_allocx
  2213.  
  2214.         move.l    d0,a6
  2215.         move.b    #CPU_JOYPORT,d0            ;joyport only.
  2216.         jsr    cpAlloc(a6)            ;allocate the port.
  2217.         move.l    d0,cp_handle            ;controlpad handler.
  2218. no_cp_allocx:    rts
  2219.  
  2220. keyb_init_yes:    move.l    exec_base,a6
  2221.         move.l    keyboard_io,a1
  2222.         move.w    #KBD_READMATRIX,IO_COMMAND(a1)    ;read events.
  2223.         move.b    #IOB_QUICK,IO_FLAGS(a1)
  2224.         move.l    keyboard_matrix,IO_DATA(a1)
  2225.         move.l    #16,IO_LENGTH(a1)
  2226.         moveq.l    #0,d0
  2227.         moveq.l    #0,d1
  2228.         lea    keyboard_device_name,a0
  2229.         jsr    OpenDevice(a6)
  2230.         rts
  2231. control_a_done:    
  2232.  
  2233. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2234. ;        possible aga preparations
  2235. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2236.  
  2237.         move.l    aga_sprs_cI,a0            ;set the lists to clear
  2238.         move.l    aga_sprs_cII,a1            ;the sprite planes.
  2239.         move.l    aga_sprs_cxI,a2
  2240.         move.l    aga_sprs_cxII,a3
  2241.         moveq.l    #256/4-1,d0
  2242. set_to_clear:    move.l    #$01010101,(a0)+
  2243.         move.l    #$01010101,(a1)+
  2244.         move.l    #$01010101,(a2)+
  2245.         move.l    #$01010101,(a3)+
  2246.         dbra    d0,set_to_clear
  2247.  
  2248.         tst.b    old_render            ;aga mode?
  2249.         bne.w    no_aga_init            ;nope.
  2250.  
  2251.         move.l    aga_scr_cI,a0
  2252.         tst.b    old_refresh            ;144/144 mode?
  2253.         beq.s    yes_144_144            ;yep.
  2254.         move.w    #$ffff,(a0)
  2255.         bra.s    c_end_fix_done
  2256. yes_144_144:    move.w    #$2d11,(a0)
  2257.  
  2258. c_end_fix_done:    bsr.w    compute_aga_bg            ;compute the colour tables.
  2259.         bsr.w    compute_aga_spr
  2260.  
  2261.         move.l    graphics_base,a6
  2262.             move.l  $22(a6),old_wb_view        ;store current view.
  2263.         move.l     38(a6),old_copper
  2264.         move.w    dmaconr+$dff000,old_dmareq
  2265.  
  2266.         move.l    aga_map_I,d0
  2267.         move.l    aga_pln_cI,a0
  2268.         moveq.l    #8-1,d1
  2269.         moveq.l    #40,d2                ;modulus.
  2270.         bsr.w    load_bitplanes            ;load planes.
  2271.  
  2272.         move.l    aga_spr_Ix,a0
  2273.         move.l    aga_spr_IIx,a1
  2274.         move.l    aga_spr_IIIx,a2
  2275.         move.w    #20,(a0)
  2276.         move.w    #144*256,8(a0)
  2277.         move.w    #20,(a1)
  2278.         move.w    #144*256,8(a1)
  2279.         move.w    #20,(a2)
  2280.         move.w    #144*256,8(a2)
  2281.         add.l    #16,a0
  2282.         add.l    #16,a1
  2283.         add.l    #16,a2
  2284.         move.w    #144*2*2-1,d0
  2285.         move.l    #$ffffffff,d1
  2286. make_mask_sprs:    move.l    d1,(a0)+
  2287.         move.l    d1,(a1)+
  2288.         move.l    d1,(a2)+
  2289.         dbra    d0,make_mask_sprs
  2290.  
  2291.         move.l    aga_spr_cI,a0
  2292.         move.l    aga_spr_empty,a1
  2293.         move.w    #20,(a1)
  2294.         move.w    #1*256,8(a1)
  2295.         moveq.l    #8-1,d0
  2296.         move.l    a1,d1
  2297. sprite_null_ptr:move.w    d1,6(a0)
  2298.         swap    d1
  2299.         move.w    d1,2(a0)
  2300.         swap    d1
  2301.         addq.l    #8,a0
  2302.         dbra    d0,sprite_null_ptr
  2303.  
  2304.         move.l    aga_spr_cI,a0            ;output.
  2305.         add.l    #8*4,a0
  2306.         lea    aga_spr_Ix,a1
  2307.         moveq.l    #3-1,d0
  2308. load_mask_ptrs:    move.l    (a1)+,d1
  2309.         move.w    d1,6(a0)
  2310.         swap    d1
  2311.         move.w    d1,2(a0)
  2312.         addq.l    #8,a0
  2313.         dbra    d0,load_mask_ptrs
  2314.  
  2315.         lea    aga_spr_Ia,a0
  2316.         moveq.l    #6-1,d0
  2317. hide_sprites:    move.l    (a0)+,a1
  2318.         move.w    #20,(a1)
  2319.         dbra    d0,hide_sprites
  2320.  
  2321.         move.l    intuition_base,a6
  2322.         sub.l    a0,a0                ;no newscreen structure.
  2323.         lea    block_screen_taglist,a1        ;only tagitems. 
  2324.  
  2325.         tst.b    aga_mode
  2326.         beq.s    aga_mode_pal
  2327. aga_mode_ntsc:    move.l    #NTSC_MONITOR_ID!LORES_KEY,block_screen_id+4
  2328.         bra.s    aga_mode_done
  2329. aga_mode_pal:    move.l    #PAL_MONITOR_ID!LORES_KEY,block_screen_id+4
  2330.  
  2331. aga_mode_done:    jsr    OpenScreenTagList(a6)
  2332.         move.l    d0,block_screen_ptr
  2333. ;        beq.w    quit_db
  2334.  
  2335.         move.l    dos_base,a6
  2336.         moveq.l    #2,d1
  2337.         jsr    Delay(a6)
  2338.  
  2339.         move.l  graphics_base,a6
  2340. ;        sub.l    a1,a1
  2341. ;        jsr    LoadView(a6)            ;flush view to nothing.
  2342.         jsr    WaitTOF(a6)            ;wait once.
  2343.         jsr    WaitTOF(a6)            ;wait again.
  2344.         move.l    copper_I,cop1lc+$dff000        ;install copper list.
  2345.  
  2346.         move.l    copper_II,copper_inactive
  2347.         move.l    aga_map_II,aga_map_inactive
  2348.         move.l    aga_ro_list_II,aga_ro_inactive
  2349.         move.l    #bg_scroll_y_II,bg_scroll_inactive
  2350.         move.l    #aga_spr_Ib,aga_spr_inactive_pointer
  2351.         clr.b    aga_palette_byte        ;start palette = 00.
  2352.  
  2353.         move.l    exec_base,a6
  2354.         lea    get_vbr,a5            ;the subroutine.
  2355.         jsr    Supervisor(a6)            ;enter supervisor!
  2356.         bra.s    vbr_obtained            ;fetch completed.
  2357.  
  2358. get_vbr:    movec    VBR,d0                ;take the pointer.
  2359.         move.l    d0,vbr_pointer            ;store the pointer.
  2360.         rte                    ;exit supervisor.
  2361.  
  2362. vbr_obtained:    move.l    vbr_pointer,a0            ;from memory with love.
  2363.         move.l    $6c(a0),old_vbr            ;take the old.
  2364.            move.l    #vbr_interrupt,$6c(a0)        ;install an interrupt.
  2365.  
  2366. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2367. ;        normal procedures before starting the game
  2368. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2369.  
  2370. no_aga_init:    move.l    aga_sprs_cxII,aga_sprs_inactive_x
  2371.         move.l    aga_sprs_cII,aga_sprs_inactive    ;this one is universally
  2372.                             ;used.
  2373.         move.l    exec_base,a6
  2374.         jsr    CacheClearU(a6)            ;clear the cache first.
  2375.  
  2376.         tst.b    new_load
  2377.         beq.s    no_new_load            ;using an old rom image.
  2378.  
  2379.         clr.b    new_load
  2380.         bsr.w    run_cartridge            ;run the cartridge!
  2381.  
  2382.         bra.s    back_to_menu
  2383. no_new_load:    clr.b    input_status            ;clear the pause flag.
  2384.         bsr.w    cartridge_loop            ;run the cartridge!
  2385.  
  2386. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2387. ;        game has been paused - return to the normal order via
  2388. ;        these small routines
  2389. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2390.  
  2391. back_to_menu:    bsr.w    turn_ahi_off            ;turn off the sounds.
  2392.  
  2393.         lea    status_paused_txt,a5
  2394.         bsr.w    print_status_middle
  2395.  
  2396.         lea    menu_ptr,a0
  2397.         bsr.w    clear_window_pointer
  2398.         lea    function_ptr,a0
  2399.         bsr.w    clear_window_pointer
  2400.         lea    wzonka_ptr,a0
  2401.         bsr.w    clear_window_pointer
  2402.  
  2403.         lea    joy_item_list,a0
  2404.         moveq.l    #0,d0
  2405.         move.b    keystick,d0
  2406.         move.b    (a0,d0.l),d1
  2407.         beq.s    keyb_return            ;keyboard.
  2408.         cmp.b    #1,d1                ;cd³² joypad?
  2409.         beq.s    cd32_return
  2410.         cmp.b    #2,d1                ;sega 4 button pad?
  2411.         beq.s    sega_4b_return
  2412.         cmp.b    #3,d1                ;sega 2 button pad?
  2413.         beq.s    sega_2b_return
  2414.         cmp.b    #4,d1                ;1b joystick?
  2415.         beq.s    joystick_return        
  2416.         cmp.b    #5,d1                ;2b joystick?
  2417.         beq.s    joystick_return        
  2418.  
  2419.         bra.w    get_message            ;the others - do nothing.
  2420.  
  2421. cd32_return:    move.l    exec_base,a6
  2422.         move.l    low_level_base,d0
  2423.         beq.w    get_message
  2424.         move.l    d0,a1
  2425.         jsr    CloseLibrary(a6)
  2426.         bra.w    get_message
  2427.  
  2428. sega_4b_return:    bsr.b    sega_return            ;free sega resources.
  2429.         bra.w    get_message
  2430.  
  2431. sega_2b_return:    bsr.b    keyb_free_yes            ;free keyboard and
  2432.         bsr.b    sega_return            ;sega resources.
  2433.         bra.w    get_message
  2434.  
  2435. keyb_return:    bsr.b    keyb_free_yes
  2436.         bra.w    get_message
  2437.  
  2438. joystick_return:bsr.b    keyb_free_yes
  2439.         bra.w    get_message
  2440.  
  2441. sega_return:    move.l    control_pad_base,d0        ;sega controller.
  2442.         beq.w    sega_xit
  2443.         move.l    d0,a6
  2444.         move.l    cp_handle,a0
  2445.         jsr    cpFree(a6)            ;free the allocated info
  2446.                             ;block area.
  2447.         move.l    control_pad_base,a1
  2448.         move.l    exec_base,a6
  2449.         jsr    CloseLibrary(a6)
  2450.         clr.l    control_pad_base
  2451. sega_xit:    rts
  2452.  
  2453. keyb_free_yes:    move.l    exec_base,a6            ;keyboard controller fix.
  2454.         move.l    keyboard_io,a1
  2455.         jsr    AbortIO(a6)
  2456.  
  2457.         move.l    keyboard_io,a1
  2458.         jsr    CloseDevice(a6)
  2459.         rts
  2460.  
  2461. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2462. ;        compute an aga h/w colour tables
  2463. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2464.  
  2465. compute_aga_bg:    move.l    aga_col_bg,a0
  2466.         lea    gameboy_colours,a1
  2467.         bra.s    create_colours
  2468.  
  2469. compute_aga_spr:move.l    aga_col_sprs,a0
  2470.         lea    gameboy_colours+4*4,a1
  2471.  
  2472. create_colours:    moveq.l    #0,d0
  2473. create_colour:    move.l    d0,d1
  2474.         and.b    #%11,d1
  2475.         bsr.b    create_col            ;colour 0.
  2476.         move.l    d0,d1
  2477.         and.b    #%1100,d1
  2478.         lsr.b    #2,d1
  2479.         bsr.b    create_col            ;colour 1.
  2480.         move.l    d0,d1
  2481.         and.b    #%110000,d1
  2482.         lsr.b    #4,d1
  2483.         bsr.b    create_col            ;colour 2.
  2484.         move.l    d0,d1
  2485.         lsr.b    #6,d1
  2486.         bsr.b    create_col            ;colour 3.
  2487.  
  2488.         cmp.b    #$ff,d0
  2489.         beq.s    compute_exit
  2490.         addq.b    #1,d0
  2491.         bra.b    create_colour
  2492. compute_exit:    rts
  2493.  
  2494. create_col:    lea    (a1,d1.l*4),a2            ;a2 = colour values.
  2495.         move.b    1(a2),d2            ;d2 = r.
  2496.         move.b    2(a2),d3            ;d3 = g.
  2497.         move.b    3(a2),d4            ;d4 = b.
  2498.  
  2499.         moveq.l    #0,d5
  2500.         move.b    d2,d5
  2501.         lsl.w    #4,d5
  2502.         move.b    d3,d5
  2503.         move.b    d4,d6
  2504.         lsr.b    #4,d6
  2505.         and.b    #%11110000,d5
  2506.         or.b    d6,d5                ;d5 = rgb (h).
  2507.         move.w    d5,(a0)+
  2508.  
  2509.         and.b    #%00001111,d2
  2510.         lsl.w    #8,d2
  2511.         move.b    d3,d2
  2512.         lsl.b    #4,d2
  2513.         and.b    #%00001111,d4
  2514.         or.b    d4,d2                ;d2 = rgb (l).
  2515.         move.w    d2,(a0)+
  2516.         rts
  2517.  
  2518. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2519. ;        allocate a double buffered game screen
  2520. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2521.  
  2522. dbuf_alloc:    tst.l    cyber_base
  2523.         bne.w    alloc_cyber_screen_data
  2524.  
  2525.         bsr.w    dbuf_dealloc            ;free the old stuff.
  2526.  
  2527.         move.l    gb_bmap_I,a0
  2528.         move.l    gb_bplanes_I,a1            ;planes.
  2529.         bsr.w    dbuf_init
  2530.  
  2531.         move.l    gb_bmap_II,a0
  2532.         move.l    gb_bplanes_II,a1        ;planes.
  2533.         bsr.w    dbuf_init
  2534.  
  2535.         move.l    gb_bplanes_I,a0
  2536.         move.l    a0,bitmap_bg            ;background.
  2537.         add.l    d0,a0                ;to bitmap 1 (0, 1, 2, 3).
  2538.         add.l    d0,a0                ;to bitmap 2 (0, 1, 2, 3).
  2539.         move.l    a0,bitmap_spc            ;sprites.
  2540.  
  2541.         bsr.w    center_screen
  2542.  
  2543.         move.l    intuition_base,a6
  2544.         sub.l    a0,a0                ;no newscreen structure.
  2545.         lea    gb_taglist,a1            ;only tagitems. 
  2546.         jsr    OpenScreenTagList(a6)
  2547.         move.l    d0,gb_screen_ptr
  2548.         beq.w    quit_db
  2549.  
  2550.         move.l    graphics_base,a6
  2551.         move.l    gb_rport_I,a1
  2552.         jsr    InitRastPort(a6)
  2553.         move.l    gb_rport_II,a1
  2554.         jsr    InitRastPort(a6)
  2555.  
  2556.         move.l    gb_rport_I,a0
  2557.         move.l    gb_bmap_I,rp_BitMap(a0)
  2558.         move.l    gb_rport_II,a0
  2559.         move.l    gb_bmap_II,rp_BitMap(a0)
  2560.  
  2561. dbuf_alloc_done:moveq.l    #0,d0                ;no errors.
  2562.         rts
  2563.  
  2564. quit_db:    moveq.l    #1,d0                ;error!
  2565.         rts
  2566.  
  2567. dbuf_init:    tst.b    old_refresh            ;mode 144/144?
  2568.         bne.s    normal_dbuf            ;no.
  2569.         move.l    #160/8*144,d0            ;yes.
  2570.         move.l    #160,d1
  2571.         move.l    #144,d2
  2572.         bra.s    dbuf_init_ok
  2573. normal_dbuf:    move.l    #gb_screen_x/8*gb_screen_y,d0
  2574.         move.l    #gb_screen_x,d1            ;width.
  2575.         move.l    #gb_screen_y,d2            ;height.
  2576.  
  2577. dbuf_init_ok:    move.l    d0,-(SP)            ;for the pointers.
  2578.  
  2579.         lea    bm_Planes(a0),a2
  2580.         move.l    a1,a5
  2581.         move.l    a1,(a2)+
  2582.         add.l    d0,a1
  2583.         move.l    a1,(a2)+
  2584.         add.l    d0,a1
  2585.         move.l    a1,(a2)+
  2586.         add.l    d0,a1
  2587.         move.l    a1,(a2)                ;stored the all pointers.
  2588.  
  2589.         move.l    d0,d7
  2590.         subq.l    #1,d7
  2591. dbuf_clear:    clr.l    (a5)+
  2592.         dbra    d7,dbuf_clear            ;clear buffer.
  2593.  
  2594.         move.l    graphics_base,a6
  2595.         moveq.l    #4,d0                ;depth.
  2596.         jsr    InitBitMap(a6)            ;init the structure.
  2597.  
  2598.         move.l    (SP)+,d0
  2599.         rts
  2600.  
  2601. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2602. ;        center screen
  2603. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2604.  
  2605. center_screen:    clr.l    gb_taglist_x+4
  2606.  
  2607.         move.l    graphics_base,a6
  2608.         move.l    gb_screen_id+4,d0
  2609.         jsr    FindDisplayInfo(a6)
  2610.         move.l    d0,display_info_handle
  2611.         beq.s    center_screen_exit
  2612.  
  2613.         move.l    d0,a0
  2614.         move.l    dimension_info,a1
  2615.         move.l    #dim_SIZEOF,d0
  2616.         move.l    #DTAG_DIMS,d1
  2617.         move.l    gb_screen_id,d2
  2618.         jsr    GetDisplayInfoData(a6)
  2619.         tst.l    d0
  2620.         beq.s    center_screen_exit
  2621.  
  2622.         moveq.l    #0,d0
  2623.         move.l    dimension_info,a0
  2624.         lea    dim_StdOScan(a0),a0
  2625.         move.w    ra_MaxX(a0),d0
  2626.         sub.w    #160,d0
  2627.         lsr.w    #1,d0
  2628.  
  2629.         move.l    d0,gb_taglist_x+4
  2630.  
  2631. center_screen_exit:
  2632.         rts
  2633.  
  2634. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2635. ;        allocate and initialize data structures for
  2636. ;        a cybergraphics screen
  2637. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2638.  
  2639. alloc_cyber_screen_data:
  2640.         bsr.w    cyber_screen_dealloc
  2641.  
  2642.         move.l    gb_bmap_I,a0
  2643.         move.l    gb_bplanes_I,a1
  2644.         bsr.w    dbuf_init
  2645.  
  2646.         move.l    gb_bmap_II,a0
  2647.         move.l    gb_bplanes_II,a1
  2648.         bsr.w    dbuf_init
  2649.  
  2650.         move.l    gb_bplanes_I,a0
  2651.         move.l    a0,bitmap_bg            ;background.
  2652.         add.l    d0,a0                ;to bitmap 1 (0, 1, 2, 3).
  2653.         add.l    d0,a0                ;to bitmap 2 (0, 1, 2, 3).
  2654.         move.l    a0,bitmap_spc            ;sprites.
  2655.  
  2656.         bsr.w    center_screen
  2657.  
  2658.         move.l    intuition_base,a6
  2659.         sub.l    a0,a0                ;no newscreen structure.
  2660.         lea    gb_taglist,a1            ;only tagitems. 
  2661.         jsr    OpenScreenTagList(a6)
  2662.         move.l    d0,gb_screen_ptr
  2663.         beq.w    quit_cyber_screen_alloc
  2664.  
  2665.         move.l    graphics_base,a6
  2666.         move.l    gb_rport_I,a1
  2667.         jsr    InitRastPort(a6)
  2668.         move.l    gb_rport_II,a1
  2669.         jsr    InitRastPort(a6)
  2670.  
  2671.         move.l    gb_rport_I,a0
  2672.         move.l    game_tmp_rast_port,a1
  2673.         bsr.w    copy_rast_port
  2674.  
  2675.         move.l    graphics_base,a6
  2676.         move.l    #160,d0
  2677.         tst.b    old_refresh            ;mode 144/144?
  2678.         beq.s    no_value_fix            ;yes.
  2679.         move.l    #gb_screen_x,d0
  2680. no_value_fix:    moveq.l    #1,d1
  2681.         moveq.l    #4,d2
  2682.         moveq.l    #0,d3
  2683.         sub.l    a0,a0
  2684.         jsr    AllocBitMap(a6)
  2685.         move.l    d0,cyber_tmp_read_bitmap
  2686.  
  2687.         move.l    game_tmp_rast_port,a1
  2688.         clr.l    rp_Layer(a1)
  2689.         move.l    d0,rp_BitMap(a1)
  2690.  
  2691.         move.l    gb_rport_I,a0
  2692.         move.l    gb_bmap_I,rp_BitMap(a0)
  2693.         move.l    gb_rport_II,a0
  2694.         move.l    gb_bmap_II,rp_BitMap(a0)
  2695.  
  2696.         moveq.l    #0,d0
  2697.         rts
  2698.  
  2699. quit_cyber_screen_alloc:
  2700.         moveq.l    #1,d0
  2701.         rts
  2702.  
  2703. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2704. ;        free screen buffers and a screen
  2705. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2706.  
  2707. dbuf_dealloc:    move.l    intuition_base,d0
  2708.         beq.s    quit_gb_scr
  2709.         move.l    d0,a6
  2710.         move.l    gb_screen_ptr,d0
  2711.         beq.s    quit_gb_scr            ;no screen opened.
  2712.         move.l    d0,a0
  2713.         jsr    CloseScreen(a6)
  2714.         clr.l    gb_screen_ptr
  2715.  
  2716. quit_gb_scr:    rts
  2717.  
  2718. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2719. ;        free screen buffers and a screen
  2720. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2721.  
  2722. cyber_screen_dealloc:
  2723.         lea    cyber_tmp_read_bitmap,a1
  2724.         bsr.w    free_bit_maps
  2725.  
  2726.         move.l    intuition_base,d0
  2727.         beq.s    quit_cyber_scr
  2728.         move.l    d0,a6
  2729.         move.l    gb_screen_ptr,d0
  2730.         beq.s    quit_cyber_scr            ;no screen opened.
  2731.         move.l    d0,a0
  2732.         jsr    CloseScreen(a6)
  2733.         clr.l    gb_screen_ptr
  2734.  
  2735. quit_cyber_scr:    rts
  2736.  
  2737. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2738. ;        different sized input buffers for graphics data
  2739. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2740.  
  2741. init_wzonka_176:move.l    graphics_base,a6
  2742.         move.l    game_rast_port,a1
  2743.         jsr    InitRastPort(a6)
  2744.  
  2745.         move.l    game_rast_port,a0
  2746.         move.l    game_tmp_rast_port,a1
  2747.         bsr.w    copy_rast_port
  2748.  
  2749.         move.l    wzonka_map,bitmap_bg        ;planes 0 and 1.
  2750.         move.l    wzonka_map,bitmap_spc        ;sprite planes (2 and 3).
  2751.         add.l    #gb_screen_x/8*gb_screen_y*2,bitmap_spc
  2752.  
  2753.         move.l    wzonka_map_attr,a0
  2754.         lea    bm_Planes(a0),a0        ;plane pointers.
  2755.         move.l    bitmap_bg,a1
  2756.         move.l    #gb_screen_x/8*gb_screen_y,d0
  2757.         bsr.w    init_bitmap
  2758.  
  2759.         move.l    graphics_base,a6
  2760.         move.l    wzonka_map_attr,a0
  2761.         moveq.l    #4,d0                ;depth.
  2762.         move.l    #gb_screen_x,d1            ;width.
  2763.         move.l    #gb_screen_y,d2            ;height.
  2764.         jsr    InitBitMap(a6)            ;init the structure.
  2765.  
  2766.         move.l    #gb_screen_x,d0
  2767.         move.l    wzonka_map_attr,a4
  2768.         lea    game_tmp_map_attr,a5
  2769.         bsr.w    alloc_bit_map_other
  2770.  
  2771.         move.l    d0,a0
  2772.         move.w    #gb_screen_x/8,bm_BytesPerRow(a0)
  2773.         move.w    #1,bm_Rows(a0)
  2774.  
  2775.         move.l    game_rast_port,a0
  2776.         move.l    wzonka_map_attr,rp_BitMap(a0)
  2777.         move.l    game_tmp_rast_port,a0
  2778.         move.l    game_tmp_map_attr,rp_BitMap(a0)
  2779.         clr.l    rp_Layer(a0)
  2780.  
  2781.         bra.w    allocate_window_output
  2782.  
  2783. init_wzonka_160:move.l    graphics_base,a6
  2784.         move.l    game_rast_port,a1
  2785.         jsr    InitRastPort(a6)
  2786.  
  2787.         move.l    game_rast_port,a0
  2788.         move.l    game_tmp_rast_port,a1
  2789.         bsr.w    copy_rast_port
  2790.  
  2791.         move.l    wzonka_map,bitmap_bg        ;planes 0 and 1.
  2792.         move.l    wzonka_map,bitmap_spc        ;sprite planes (2 and 3).
  2793.         add.l    #160/8*144*2,bitmap_spc
  2794.  
  2795.         move.l    wzonka_map_attr,a0
  2796.         lea    bm_Planes(a0),a0        ;plane pointers.
  2797.         move.l    bitmap_bg,a1
  2798.         move.l    #160/8*144,d0
  2799.         bsr.w    init_bitmap
  2800.  
  2801.         move.l    graphics_base,a6
  2802.         move.l    wzonka_map_attr,a0
  2803.         moveq.l    #4,d0                ;depth.
  2804.         move.l    #160,d1                ;width.
  2805.         move.l    #144,d2                ;height.
  2806.         jsr    InitBitMap(a6)            ;init the structure.
  2807.  
  2808.         move.l    #160,d0
  2809.         move.l    wzonka_map_attr,a4
  2810.         lea    game_tmp_map_attr,a5
  2811.         bsr.w    alloc_bit_map_other
  2812.         tst.l    d0
  2813.         beq.w    quit
  2814.  
  2815.         move.l    d0,a0
  2816.         move.w    #160/8,bm_BytesPerRow(a0)
  2817.         move.w    #1,bm_Rows(a0)
  2818.  
  2819.         move.l    game_rast_port,a0
  2820.         move.l    wzonka_map_attr,rp_BitMap(a0)
  2821.         move.l    game_tmp_rast_port,a0
  2822.         move.l    game_tmp_map_attr,rp_BitMap(a0)
  2823.         clr.l    rp_Layer(a0)
  2824.  
  2825. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2826. ;        init new bit maps for the output routines
  2827. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2828.  
  2829. allocate_window_output:
  2830.         move.l    wzonka_ptr,a0
  2831.         move.l    wd_RPort(a0),a0
  2832.         move.l    game_output_tmp_rast_port,a1
  2833.         bsr.w    copy_rast_port
  2834.  
  2835.         move.l    wzonka_game_x,d0
  2836.         move.l    wzonka_ptr,a4
  2837.         move.l    wd_RPort(a4),a4
  2838.         move.l    rp_BitMap(a4),a4
  2839.         lea    game_output_tmp_map_attr,a5
  2840.         bsr.w    alloc_bit_map_other
  2841.  
  2842.         move.l    d0,a0
  2843.         move.l    wzonka_game_x,d0
  2844.         lsr.l    #3,d0
  2845.         move.w    d0,bm_BytesPerRow(a0)
  2846.         move.w    #1,bm_Rows(a0)
  2847.  
  2848.         move.l    game_output_tmp_rast_port,a0
  2849.         move.l    game_output_tmp_map_attr,rp_BitMap(a0)
  2850.         clr.l    rp_Layer(a0)
  2851.         rts
  2852.  
  2853. init_bitmap:    moveq.l    #4-1,d7
  2854. init_bitmap_n:    move.l    a1,(a0)+
  2855.         add.l    d0,a1
  2856.         dbra    d7,init_bitmap_n
  2857.         rts
  2858.  
  2859. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2860. ;        create copper lists for AGA modes
  2861. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2862.  
  2863. create_coppers:    move.l    copper_I,a0
  2864.         lea    aga_copper,a2
  2865.  
  2866.         move.w    #(aga_scr_0-aga_copper),d0
  2867.         bsr.b    copy_copper_d
  2868.         move.l    a0,aga_scr_0_cI
  2869.  
  2870.         move.w    #(aga_col-aga_scr_0),d0
  2871.         bsr.b    copy_copper_d
  2872.         move.l    a0,aga_col_cI
  2873.  
  2874.         move.w    #(spr_col-aga_col),d0
  2875.         bsr.b    copy_copper_d
  2876.         move.l    a0,aga_hw_spr_cI
  2877.  
  2878.         move.w    #(aga_sprites-spr_col),d0
  2879.         bsr.b    copy_copper_d
  2880.         move.l    a0,aga_spr_cI
  2881.  
  2882.         move.w    #(aga_planes-aga_sprites),d0
  2883.         bsr.b    copy_copper_d
  2884.         move.l    a0,aga_pln_cI
  2885.  
  2886.         move.w    #(aga_scr_x-aga_planes),d0
  2887.         bsr.b    copy_copper_d
  2888.         move.l    a0,aga_scr_cI
  2889.  
  2890.         move.w    #144-1,d0
  2891.         move.w    #$2d11,d1
  2892. create_rasters:    move.w    d1,(a0)+
  2893.         move.w    #$fffe,(a0)+
  2894.         move.w    #bplcon1,(a0)+
  2895.         clr.w    (a0)+
  2896.         add.w    #$100,d1            ;next raster line.
  2897.         dbra    d0,create_rasters
  2898.  
  2899.         move.l    #$fffffffe,(a0)            ;the end.
  2900.         rts
  2901.  
  2902. copy_copper_d:    lsr.w    #2,d0
  2903.         subq.w    #1,d0
  2904. copy_copper_dat:move.l    (a2)+,(a0)+
  2905.         dbra    d0,copy_copper_dat
  2906.         rts
  2907.  
  2908. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2909. ;        menu rom info
  2910. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2911.  
  2912. menu_rom_info:    bsr.w    function_window_output
  2913.         tst.l    d0
  2914.         beq.w    get_message
  2915.  
  2916.         cmp.l    #"INFO",function_status
  2917.         beq.w    get_message            ;don't output this twice.
  2918.  
  2919.         bsr.w    gadgets_rmv
  2920.  
  2921.         move.l    graphics_base,a6
  2922.         move.l    info_map_attr,a0        ;a0 = source bitmap.
  2923.         move.l    function_ptr,a1
  2924.         move.l    wd_RPort(a1),a1            ;a1 = destination rastport.
  2925.         moveq.l    #0,d0                ;org x.
  2926.         moveq.l    #0,d1                ;org y.
  2927.         moveq.l    #0,d2                ;dst x.
  2928.         moveq.l    #0,d3                ;dst y.
  2929.         move.l    #function_x_bm,d4        ;size x.
  2930.         move.l    #function_y_bm,d5        ;size y.
  2931.         move.l    #$c0,d6                ;minterm.
  2932.         jsr    BltBitMapRastPort(a6)        ;update the screen window.
  2933.  
  2934.         move.l    #"INFO",function_status
  2935.         bsr.w    do_info
  2936.  
  2937.         lea    info_win_txt,a1
  2938.         bsr.w    change_win_title
  2939.  
  2940.         bra.w    get_message
  2941.  
  2942. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2943. ;        fill the information form
  2944. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2945.  
  2946. do_info:    tst.l    cartridge
  2947.         beq.w    do_info_text            ;no changes.
  2948.  
  2949.         clr.w    d6
  2950.         bsr.w    info_text_out            ;clear the old texts.
  2951.  
  2952. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2953. ;        examine the cartridge and find the essential information
  2954. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2955.  
  2956.         clr.b    cartridge_status
  2957.         move.l    cartridge,a0
  2958.         lea    rom_table,a2
  2959.         moveq.l    #0,d0
  2960.         move.b    $148(a0),d0            ;d0 = rom size.
  2961.         cmp.w    #9,d0
  2962.         blt.s    rom_size_ok
  2963.  
  2964.         cmp.b    #$52,d0
  2965.         bne.s    rom_no_52
  2966.         move.b    #10,d0
  2967.         bra.s    rom_size_ok
  2968. rom_no_52:    cmp.b    #$53,d0
  2969.         bne.s    rom_no_53
  2970.         move.b    #11,d0
  2971.         bra.s    rom_size_ok
  2972. rom_no_53:    cmp.b    #$54,d0
  2973.         bne.s    rom_no_54
  2974.         move.b    #11,d0
  2975.         bra.s    rom_size_ok
  2976. rom_no_54:    move.b    #9,d0                ;illegal rom size!
  2977.         move.b    #1,cartridge_status        ;error!!!
  2978. rom_size_ok:    lea    rom_banks_list,a5
  2979.         move.l    (a5,d0.w*4),rom_banks_mask
  2980.         move.l    (a2,d0.l*4),d2            ;d2 = rom size text.
  2981.         move.b    $149(a0),d0            ;d0 = ram size.
  2982.         moveq.l    #0,d5
  2983.         lea    ram_banks_list,a1
  2984.         move.b    (a1,d0.l),d5
  2985.         move.l    d5,ram_banks
  2986.         lea    ram_banks_mask_list,a1
  2987.         move.b    (a1,d0.l),d5
  2988.         move.l    d5,ram_banks_mask
  2989.         lea    ram_table,a1
  2990.         cmp.w    #5,d0
  2991.         blt.s    ram_size_ok
  2992.         move.b    #5,d0                ;illegal ram size!
  2993.         move.b    #1,cartridge_status        ;error!!!
  2994. ram_size_ok:    move.l    (a1,d0.l*4),d3            ;d3 = ram size text.
  2995.  
  2996.         move.b    $147(a0),d0            ;d0 = cartridge type.
  2997.         move.l    #map_inv,battery_ptr
  2998.  
  2999.         cmp.b    #$ff,d0
  3000.         bne.s    no_huc1_d
  3001.         move.l    #map_ff,battery_ptr
  3002.         bra.s    mapper_done
  3003.  
  3004. no_huc1_d:    cmp.b    #$fe,d0
  3005.         bne.s    no_huc3_d
  3006.         move.l    #map_fe,battery_ptr
  3007.         bra.s    mapper_done
  3008.  
  3009. no_huc3_d:    cmp.b    #$fd,d0
  3010.         bne.s    no_tama5_d
  3011.         move.l    #map_fd,battery_ptr
  3012.         bra.s    mapper_done
  3013.  
  3014. no_tama5_d:    cmp.w    #$1f,d0
  3015.         bgt.s    mapper_done
  3016.  
  3017.         lea    mapper_table,a5
  3018.         move.l    (a5,d0.l*4),battery_ptr
  3019.  
  3020. mapper_done:    cmp.l    #map_inv,battery_ptr
  3021.         bne.s    mapper_id_ok
  3022.         move.b    #1,cartridge_status
  3023.  
  3024. mapper_id_ok:    add.l    #$134,a0            ;a0 = name.
  3025.  
  3026. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3027. ;        identify MBC3-mappers
  3028. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3029.  
  3030.         clr.b    mbc3_existence
  3031.         cmp.w    #$f,d0
  3032.         blt.s    no_mbc3_in_use
  3033.         cmp.w    #$13,d0
  3034.         bgt.s    no_mbc3_in_use
  3035.         move.b    #1,mbc3_existence
  3036.  
  3037. no_mbc3_in_use:
  3038.  
  3039. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3040. ;        check nintendo logo existence
  3041. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3042.  
  3043.         lea    info_txt_2,a6
  3044.         moveq.l    #$133-$104,d0
  3045.         move.l    cartridge,a2
  3046.         add.l    #$104,a2
  3047. nintendo_logo_area_test:
  3048.         tst.b    (a2)+
  3049.         bne.s    nintendo_logo_area_filthy    ;not a zero!
  3050.         dbra    d0,nintendo_logo_area_test
  3051.  
  3052. nintendo_logo_area_clean:
  3053.         move.l    #"FAN ",(a6)+
  3054.         move.l    #"SOFT",(a6)+
  3055.         move.l    #"WARE",(a6)+
  3056.         clr.b    (a6)
  3057.         bra.s    nintendo_logo_area_done
  3058.  
  3059. nintendo_logo_area_filthy:
  3060.         move.l    #"LICE",(a6)+
  3061.         move.l    #"NSED",(a6)+
  3062.         move.l    #" SOF",(a6)+
  3063.         move.l    #"TWAR",(a6)+
  3064.         move.w    #"E?",(a6)+
  3065.         clr.b    (a6)
  3066.  
  3067. nintendo_logo_area_done:
  3068.         move.l    d2,rom_ptr            ;store the pointers.
  3069.         move.l    d3,ram_ptr
  3070.  
  3071.         lea    info_txt_1,a2            ;cart name.
  3072.         moveq.l    #16-1,d2
  3073.         move.b    #'"',(a2)+
  3074.         move.l    a2,a0
  3075.         bsr.w    copy_rom_name_to_a0
  3076.         move.l    a0,a2
  3077.         move.w    #'" ',(a2)+
  3078.  
  3079.         move.l    cartridge,a0
  3080.         cmp.b    #$80,$143(a0)
  3081.         beq.s    support_cgb
  3082.         cmp.b    #$03,$146(a0)
  3083.         beq.s    support_sgb
  3084. support_dmg:    move.l    #"(GB)",(a2)+
  3085.         bra.s    support_done
  3086. support_sgb:    move.l    #"(SGB",(a2)+
  3087.         move.b    #")",(a2)+
  3088.         bra.s    support_done
  3089. support_cgb:    move.l    #"(CGB",(a2)+
  3090.         move.b    #")",(a2)+
  3091.  
  3092. support_done:    clr.b    (a2)                ;the end of the name.
  3093.         bra.s    do_info_text
  3094.  
  3095. compute_rom_checksum:
  3096.         move.l    cartridge,a0
  3097.         add.l    #$134,a0
  3098.         moveq.l    #$14d-$134-1,d0
  3099.         moveq.l    #0,d1
  3100.  
  3101. compute_rom_checksum_compute:
  3102.         add.b    (a0)+,d1
  3103.         dbra    d0,compute_rom_checksum_compute
  3104.  
  3105.         add.b    #25,d1
  3106.         beq.s    rom_checksum_ok
  3107.         move.b    #1,cartridge_status
  3108.  
  3109. rom_checksum_ok:
  3110. do_info_x:    rts                    ;no. quit.
  3111.  
  3112. do_info_text:    move.w    #$0100,d6
  3113.         bsr.w    info_text_out
  3114.         rts
  3115.  
  3116. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3117. ;        output the cartridge info texts
  3118. ;        INPUT:
  3119. ;        d6    = $0100/$0000.
  3120. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3121.  
  3122. info_text_out:    cmp.l    #"INFO",function_status
  3123.         bne.w    info_text_out_x            ;no output.
  3124.  
  3125.         lea    info_text_list,a5
  3126.         moveq.l    #5-1,d7
  3127. info_text_clr:    move.l    (a5)+,a4
  3128.         move.w    d6,(a4)                ;new colours.
  3129.         move.l    a4,a0
  3130.         bsr.w    print_middle
  3131.         dbra    d7,info_text_clr
  3132. info_text_out_x:rts
  3133.  
  3134. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3135. ;        menu gbs load
  3136. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3137.  
  3138. menu_gbs_load:
  3139.  
  3140.         bsr.b    gbs_load_get_name
  3141.         tst.l    d0
  3142.         beq.w    get_message
  3143.  
  3144.         bsr.w    gbs_load
  3145.         bra.w    get_message
  3146.  
  3147. runtime_gbs_load:
  3148.  
  3149.         movem.l    d0-d7/a0-a6,-(SP)
  3150.  
  3151.         move.l    dir_n_name_ptr,a0        ;the name of the file.
  3152.         move.l    #"T:Wz",(a0)+
  3153.         move.l    #"onka",(a0)+
  3154.         move.l    #"-Lad",(a0)+
  3155.         move.l    #".RT.",(a0)+
  3156.         move.w    #"GB",(a0)+
  3157.         move.b    #"S",(a0)+
  3158.         move.b    gbs_file_id,(a0)+
  3159.         clr.b    (a0)
  3160.  
  3161.         bsr.w    gbs_load
  3162.  
  3163.                 moveq.l #1,d0
  3164.  
  3165.         bsr.w    init_the_sound_registers
  3166.  
  3167.         movem.l    (SP)+,d0-d7/a0-a6
  3168.  
  3169. runtime_gbs_load_exit:
  3170.         rts
  3171.  
  3172. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3173. ;        gbs load routines
  3174. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3175.  
  3176. gbs_load_get_name:
  3177.  
  3178.                 moveq.l #1,d0 ;key_file_ser
  3179.  
  3180.         move.l    req_tools_base,a6
  3181.         lea    req_tags,a0            ;the tags.
  3182.         move.l    menu_ptr,4(a0)            ;the position pointer.
  3183.         move.l    request_ptr_ss,a1        ;the requester pointer.
  3184.         move.l    name_ptr,a2            ;the output area.
  3185.         lea    request_lsshot,a3        ;the title text.
  3186.         jsr    rtFileRequestA(a6)        ;open a file requester.
  3187.  
  3188.         move.l    request_ptr_ss,a2        ;directory.
  3189.         move.l    rtfi_Dir(a2),a2
  3190.         move.l    def_ss_dir,a0
  3191.         bsr.w    memorize_dir            ;memorize the dir.
  3192.  
  3193.         tst.l    d0
  3194.         beq.s    gbs_error_no_select        ;error! none selected!
  3195.  
  3196.         move.l    request_ptr_ss,a2        ;directory.
  3197.         bsr.w    parse_req_name
  3198.         moveq.l    #1,d0
  3199.  
  3200. gbs_error_no_select:
  3201.         rts
  3202.  
  3203. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3204. ;        find out if the file can be unpacked with xpk master
  3205. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3206.  
  3207. gbs_load:    move.l    xpk_master_base,d0
  3208.         beq.w    no_xpk_lss
  3209.         move.l    d0,a6
  3210.         lea    xfh_pointer,a0
  3211.         lea    xpk_in_tags,a1
  3212.         move.l    dir_n_name_ptr,4(a1)
  3213.         jsr    XpkOpen(a6)
  3214.         tst.l    d0
  3215.         bne.w    no_xpk_lss
  3216.  
  3217.         bsr.w    get_packer_name
  3218.  
  3219.         move.l    xfh_pointer,a0            ;a0 = xpkfib structure.
  3220.         move.l    xf_Type(a0),d0            ;d0 = file type.
  3221.         cmp.l    #XPKTYPE_PACKED,d0        ;is it packed?
  3222.         bne.w    quit_xpk_lss            ;no. it's something else.
  3223.  
  3224.         move.l    xf_ULen(a0),d0
  3225.         cmp.l    #$8000+$8000+1024,d0
  3226.         bgt.w    quit_lss_e            ;too big a file!
  3227.  
  3228.         move.l    d0,file_length            ;uncompressed length.
  3229.  
  3230. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3231. ;        unpack the snapshot file
  3232. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3233.  
  3234.         move.l    xfh_pointer,a0
  3235.         jsr    XpkClose(a6)
  3236.  
  3237.         move.l    dos_base,a6            ;open the data file.
  3238.         move.l    dir_n_name_ptr,d1        ;the name of the file.
  3239.         move.l    #MODE_OLDFILE,d2
  3240.         jsr    Open(a6)            ;narsk.
  3241.         move.l    d0,file_hd
  3242.         beq.w    ssload_error_file_not_found    ;file error!
  3243.  
  3244.         lea    status_xpk_unpack_txt,a5
  3245.         bsr.w    print_status_middle
  3246.  
  3247.         move.l    xpk_master_base,a6
  3248.         lea    xpk_unp_tags,a0
  3249.         move.l    file_hd,4(a0)
  3250.         move.l    snapshot_area,12(a0)
  3251.         move.l    #$2000*16+$8000+1024+XPK_MARGIN,20(a0)
  3252.                             ;output area length.
  3253.         jsr    XpkUnpack(a6)
  3254.         tst.l    d0
  3255.         bne.s    xpk_argh_lss            ;error here!
  3256.  
  3257.         move.l    dos_base,a6
  3258.         move.l    file_hd,d1
  3259.         jsr    Close(a6)            ;click.
  3260.  
  3261.         bra.w    load_ok_lss
  3262.  
  3263. xpk_argh_lss:    move.l    dos_base,a6
  3264.         move.l    file_hd,d1
  3265.         jsr    Close(a6)            ;click.
  3266.  
  3267.         move.l    xpk_master_base,a6        ;an error occurred!
  3268.         move.l    xfh_pointer,a0
  3269.         jsr    XpkClose(a6)
  3270.  
  3271.         bra.w    ssload_error_xpk_error
  3272.  
  3273. quit_lss_e:    move.l    xpk_master_base,a6        ;an error occurred!
  3274.         move.l    xfh_pointer,a0
  3275.         jsr    XpkClose(a6)
  3276.  
  3277.         bra.w    ssload_error_too_big_a_file
  3278.  
  3279. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3280. ;        normal dos open and loading
  3281. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3282.  
  3283. quit_xpk_lss:    move.l    xpk_master_base,a6
  3284.         move.l    xfh_pointer,a0            ;it was not packed.
  3285.         jsr    XpkClose(a6)
  3286.  
  3287. no_xpk_lss:    move.l    dos_base,a6
  3288.         move.l    dir_n_name_ptr,d1
  3289.         moveq.l    #ACCESS_READ,d2
  3290.         jsr    Lock(a6)
  3291.         move.l    d0,file_hd
  3292.         beq.w    ssload_error_file_not_found
  3293.  
  3294.         move.l    file_info_ptr,d2
  3295.         move.l    d0,d1
  3296.         jsr    Examine(a6)
  3297.  
  3298.         move.l    file_hd,d1
  3299.         jsr    UnLock(a6)
  3300.  
  3301.         move.l    file_info_ptr,a0
  3302.         move.l    fib_Size(a0),snapshot_size
  3303.  
  3304.         move.l    dir_n_name_ptr,d1
  3305.         move.l    #MODE_OLDFILE,d2
  3306.         jsr    Open(a6)
  3307.         move.l    d0,file_hd
  3308.         beq.w    ssload_error_file_not_found
  3309.  
  3310.         move.l    d0,d1
  3311.         move.l    snapshot_area,d2
  3312.         move.l    snapshot_size,d3
  3313.         cmp.l    #$2000*16+$8000+1024,d3
  3314.         bgt.w    ssload_error
  3315.         jsr    Read(a6)
  3316.  
  3317.         move.l    file_hd,d1
  3318.         jsr    Close(a6)
  3319.  
  3320. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3321. ;        move the data from snapshot to gameboy
  3322. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3323.  
  3324. load_ok_lss:    move.l    snapshot_area,a0
  3325.         lea    z80_registers,a1
  3326.  
  3327.         move.b    (a0)+,z80_halt
  3328. ;        move.b    (a0)+,i_1            ;old interrupt level
  3329. ;        move.b    (a0)+,i_2            ;signal bytes.
  3330. ;        move.b    (a0)+,i_3
  3331.         addq.l    #3,a0
  3332.  
  3333.         addq.l    #4,a1                ;skip code pointer     (a0).
  3334.         move.l    #z80_optcode_00,(a1)+        ;xx optcodes           (a1).
  3335.         move.l    gb_memory,(a1)+            ;pointer to pseudo ram (a2).
  3336.         move.l    a1,a3
  3337.         addq.l    #4,a1                ;skip rom pointer      (a3).
  3338.         move.l    #z80_optc_CB00,(a1)+        ;cbxx optcodes.        (a4).
  3339.  
  3340.         moveq.l    #6-1,d0
  3341. z80_reg_rest:    move.l    (a0)+,(a1)+
  3342.         dbra    d0,z80_reg_rest
  3343.  
  3344.         addq.l    #4,a0                ;compability fix.
  3345.                             ;(old z80_status.L).
  3346. ;        move.l    (a0)+,lcd_status
  3347. ;        move.l    (a0)+,timer_status
  3348. ;        move.l    (a0)+,debug_status
  3349.         add.l    #12,a0
  3350.  
  3351. ;        move.l    (a0)+,z80_cycles
  3352.         addq.l    #4,a0
  3353.  
  3354.         move.l    (a0)+,d0
  3355.         add.l    rom_32k,d0
  3356.         move.l    d0,bank_address
  3357.         move.l    (a0)+,ram_bank_no
  3358.         and.l    #%11,ram_bank_no
  3359.  
  3360.         move.l    d0,(a3)                ;install rom pointer   (a3).
  3361.         move.l    a0,-(SP)
  3362.  
  3363. fix_pc_address:    bsr.w    pull_z80
  3364.  
  3365.         tst.w    d1
  3366.         blt.s    pc_from_ram
  3367.         lea    (a3,d1.l),a0            ;install code pointer  (a0).
  3368.         move.l    a3,z80_pc_base
  3369.         bra.s    pc_accuired
  3370. pc_from_ram:    lea    (a2,d1.l),a0            ;install code pointer  (a0).
  3371.         move.l    a2,z80_pc_base
  3372.  
  3373. pc_accuired:    moveq.l    #0,d1
  3374.         swap    d0                ;debc.
  3375.         move.w    d0,d1
  3376.         clr.w    d0                ;de00.
  3377.         swap    d0                ;00de.
  3378.  
  3379.         bsr.w    push_z80
  3380.  
  3381.         move.l    (SP)+,a0
  3382.         move.l    gb_memory,a1
  3383.         add.l    #$8000,a1
  3384.         move.w    #($10000-$8000)/4-1,d0
  3385. mem_rest_I:    move.l    (a0)+,(a1)+
  3386.         dbra    d0,mem_rest_I
  3387.  
  3388.         move.l    (a0)+,d0            ;restore the banks, too?
  3389.         beq.s    no_banks_rest            ;no.
  3390.         cmp.l    #1,d0
  3391.         beq.s    no_banks_rest            ;no.
  3392.  
  3393.         move.l    d0,four_ram_banks_from_gbs
  3394.         move.l    memory_banks,a1
  3395.         mulu.l    #$2000/4,d0
  3396. mem_rest_II:    move.l    (a0)+,(a1)+
  3397.         subq.l    #1,d0
  3398.         bne.s    mem_rest_II
  3399.  
  3400. no_banks_rest:    move.b    (a0)+,i_flag            ;interrupt flag.
  3401.         clr.b    new_load            ;snapshot loading invalidates
  3402.                             ;the new_load flag.
  3403.         lea    status_gbs_loaded_txt,a5
  3404.         bsr.w    print_status_middle
  3405.  
  3406. ssload_error:    rts
  3407.  
  3408. ssload_error_file_not_found:
  3409.         lea    status_file_not_found_txt,a5
  3410.         bsr.w    print_status_middle
  3411.         rts
  3412.  
  3413. ssload_error_xpk_error:
  3414.         lea    status_xpk_error_txt,a5
  3415.         bsr.w    print_status_middle
  3416.         rts
  3417.  
  3418. ssload_error_too_big_a_file:
  3419.         lea    status_too_big_a_file_txt,a5
  3420.         bsr.w    print_status_middle
  3421.         rts
  3422.  
  3423. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3424. ;        gbs save
  3425. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3426.  
  3427. menu_gbs_save:
  3428.  
  3429.         bsr.b    gbs_save_encode
  3430.         bsr.w    gbs_save_request
  3431.  
  3432.         bra.w    get_message
  3433.  
  3434. runtime_gbs_save:
  3435.  
  3436.         movem.l    d0-d7/a0-a6,-(SP)
  3437.  
  3438.         move.l    dir_n_name_ptr,a0        ;the name of the file.
  3439.         move.l    #"T:Wz",(a0)+
  3440.         move.l    #"onka",(a0)+
  3441.         move.l    #"-Lad",(a0)+
  3442.         move.l    #".RT.",(a0)+
  3443.         move.w    #"GB",(a0)+
  3444.         move.b    #"S",(a0)+
  3445.         move.b    gbs_file_id,(a0)+
  3446.         clr.b    (a0)
  3447.  
  3448.         bsr.w    gbs_save_encode
  3449.  
  3450.         move.b    pck_xpk_status,d6
  3451.         move.l    snapshot_area,a5
  3452.         move.l    snapshot_size,d7
  3453.         bsr.w    save_file
  3454.  
  3455.         movem.l    (SP)+,d0-d7/a0-a6
  3456.  
  3457. runtime_gbs_save_exit:
  3458.         rts
  3459.  
  3460. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3461. ;        gbs save routines
  3462. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3463.  
  3464.                 moveq.l #1,d0
  3465.  
  3466. gbs_save_encode:bsr.w    pull_z80
  3467.         move.l    a0,d7
  3468.         sub.l    z80_pc_base,d7
  3469.  
  3470.         move.l    snapshot_area,a0
  3471.         move.b    z80_halt,(a0)+
  3472. ;        move.b    i_1,(a0)+            ;old interrupt level
  3473. ;        move.b    i_2,(a0)+            ;signal bytes.
  3474. ;        move.b    i_3,(a0)+
  3475.         addq.l    #3,a0                ;4.
  3476.  
  3477.         swap    d0
  3478.         move.w    d1,d0
  3479.         swap    d0
  3480.         move.l    d0,(a0)+            ;bcde stored (d0).
  3481.  
  3482.         move.l    d7,(a0)+            ;pc stored   (d1).
  3483.         move.l    d2,(a0)+            ;hl stored   (d2).
  3484.         move.l    d3,(a0)+            ;fa stored   (d3).
  3485.         move.l    d4,(a0)+            ;ccr stored  (d4).
  3486.         move.l    d5,(a0)+            ;sp stored   (d5).
  3487.  
  3488.         addq.l    #4,a0                ;compability fix.
  3489.                             ;(old z80_status.L).
  3490. ;        move.l    lcd_status,(a0)+
  3491. ;        move.l    timer_status,(a0)+
  3492. ;        move.l    debug_status,(a0)+
  3493.         add.l    #12,a0                ;44.
  3494.  
  3495.         move.l    z80_cycles,(a0)+
  3496.         move.l    bank_address,d0
  3497.         sub.l    rom_32k,d0
  3498.         move.l    d0,(a0)+
  3499.         move.l    ram_bank_no,(a0)+        ;56.
  3500.  
  3501.         move.l    gb_memory,a1
  3502.         add.l    #$8000,a1
  3503.         move.w    #($10000-$8000)/4-1,d0
  3504. mem_copy_I:    move.l    (a1)+,(a0)+
  3505.         dbra    d0,mem_copy_I
  3506.  
  3507.         tst.l    ram_banks            ;save the banks, too?
  3508.         beq.s    no_banks_save            ;no.
  3509.         cmp.l    #1,ram_banks
  3510.         beq.s    no_banks_save            ;no.
  3511.  
  3512.         move.l    ram_banks,(a0)+            ;banks marker (4/16).
  3513.         move.l    memory_banks,a1
  3514.         move.l    #$2000/4,d0
  3515.         mulu.l    ram_banks,d0
  3516. mem_copy_II:    move.l    (a1)+,(a0)+
  3517.         subq.l    #1,d0
  3518.         bne.s    mem_copy_II
  3519.         bra.s    copy_done
  3520.  
  3521. no_banks_save:    clr.l    (a0)+                ;no banks saved.
  3522.  
  3523. copy_done:    move.b    i_flag,(a0)+            ;save interrupt flag.
  3524.  
  3525.             sub.l    snapshot_area,a0
  3526.         move.l    a0,snapshot_size        ;save the size.
  3527.         rts
  3528.  
  3529. gbs_save_request:
  3530.         move.l    req_tools_base,a6
  3531.         lea    req_tags,a0            ;the tags.
  3532.         move.l    menu_ptr,4(a0)            ;the position pointer.
  3533.         move.l    request_ptr_ss,a1        ;the requester pointer.
  3534.         move.l    name_ptr,a2            ;the output area.
  3535.         lea    request_ssshot,a3        ;the title text.
  3536.         jsr    rtFileRequestA(a6)        ;open a file requester.
  3537.  
  3538.         move.l    request_ptr_ss,a2        ;directory.
  3539.         move.l    rtfi_Dir(a2),a2
  3540.         move.l    def_ss_dir,a0
  3541.         bsr.w    memorize_dir            ;memorize the dir.
  3542.  
  3543.         tst.l    d0
  3544.         beq.w    gbs_save_exit
  3545.  
  3546.         move.l    request_ptr_ss,a2        ;directory.
  3547.         bsr.w    parse_req_name
  3548.  
  3549.         move.b    pck_xpk_status,d6
  3550.         move.l    snapshot_area,a5
  3551.         move.l    snapshot_size,d7
  3552.         bsr.b    save_file
  3553.  
  3554.                 moveq.l #1,d0
  3555.  
  3556. gbs_save_exit:    rts
  3557.  
  3558. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3559. ;        save file
  3560. ;        INPUT:
  3561. ;        d6    = use xpk packing (0 = yes / 1 = no).
  3562. ;        d7    = size of the area.
  3563. ;        a5    = pointer to the area.
  3564. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3565.  
  3566. save_file:    move.l    dos_base,a6            ;open the data file.
  3567.         move.l    dir_n_name_ptr,d1        ;the name of the file.
  3568.         move.l    #MODE_NEWFILE,d2
  3569.         jsr    Open(a6)
  3570.         move.l    d0,file_hd
  3571.         beq.w    file_save_error
  3572.  
  3573.         tst.l    xpk_master_base
  3574.         beq.w    no_xpk_file_save
  3575.  
  3576.         tst.b    d6                ;none lib??
  3577.         bne.w    no_xpk_file_save
  3578.  
  3579. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3580. ;        pack the file
  3581. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3582.  
  3583.         movem.l    d7/a5,-(SP)
  3584.         move.l    pck_method,status_xpk_name_txt    ;show packer name.
  3585.         lea    status_xpk_pack_txt,a5
  3586.         bsr.w    print_status_middle
  3587.         movem.l    (SP)+,d7/a5
  3588.  
  3589.         move.l    xpk_master_base,a6
  3590.         lea    xpk_pck_tags,a0
  3591.         move.l    file_hd,4(a0)
  3592.         move.l    a5,12(a0)
  3593.         move.l    d7,20(a0)
  3594.         jsr    XpkPack(a6)
  3595.         tst.l    d0
  3596.         bne.s    quit_file_save_error
  3597.  
  3598.         move.l    dos_base,a6
  3599.         move.l    file_hd,d1
  3600.         jsr    Close(a6)
  3601.  
  3602.         lea    status_file_saved_txt,a5
  3603.         bsr.w    print_status_middle
  3604.         rts
  3605.  
  3606. quit_file_save_error:
  3607.         move.l    dos_base,a6
  3608.         move.l    file_hd,d1
  3609.         jsr    Close(a6)
  3610.         bra.w    file_save_error
  3611.  
  3612. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3613. ;        normal dos open and saving
  3614. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3615.  
  3616. no_xpk_file_save:
  3617.         move.l    dos_base,a6
  3618.         move.l    d0,d1
  3619.         move.l    a5,d2
  3620.         move.l    d7,d3
  3621.         jsr    Write(a6)
  3622.  
  3623.         move.l    file_hd,d1
  3624.         jsr    Close(a6)
  3625.  
  3626.         lea    status_file_saved_txt,a5
  3627.         bsr.w    print_status_middle
  3628.         rts
  3629.  
  3630. file_save_error:lea    status_file_saved_error_txt,a5
  3631.         bsr.w    print_status_middle
  3632.         rts
  3633.  
  3634. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3635. ;        load file
  3636. ;        INPUT:
  3637. ;        d7    = size of the area.
  3638. ;        a5    = pointer to the area.
  3639. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3640.  
  3641. load_file:    move.l    xpk_master_base,d0
  3642.         beq.w    load_file_no_xpk_open
  3643.         move.l    d0,a6
  3644.         lea    xfh_pointer,a0
  3645.         lea    xpk_in_tags,a1
  3646.         move.l    dir_n_name_ptr,4(a1)
  3647.         jsr    XpkOpen(a6)
  3648.         tst.l    d0
  3649.         bne.w    load_file_no_xpk_open
  3650.  
  3651.         move.l    xfh_pointer,a0            ;a0 = xpkfib structure.
  3652.         move.l    xf_Type(a0),d0            ;d0 = file type.
  3653.         cmp.l    #XPKTYPE_PACKED,d0        ;is it packed?
  3654.         bne.w    load_file_quit_xpk        ;no. it's something else.
  3655.  
  3656.         move.l    xf_ULen(a0),file_length        ;uncompressed length.
  3657.         cmp.l    file_length,d7
  3658.         bne.w    load_file_quit_xpk_e
  3659.         add.l    #XPK_MARGIN,file_length        ;xpk margin area.
  3660.  
  3661. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3662. ;        unpack the file
  3663. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3664.  
  3665.         bsr.w    print_status_middle_erase
  3666.         bsr.w    get_packer_name
  3667.  
  3668.         move.l    xpk_master_base,a6
  3669.         move.l    xfh_pointer,a0
  3670.         jsr    XpkClose(a6)
  3671.  
  3672.         move.l    dos_base,a6            ;open the data file.
  3673.         move.l    dir_n_name_ptr,d1        ;the name of the file.
  3674.         move.l    #MODE_OLDFILE,d2
  3675.         jsr    Open(a6)
  3676.         move.l    d0,file_hd
  3677.         beq.w    load_file_quit_xpk_e
  3678.  
  3679.         move.l    a5,-(SP)
  3680.         lea    status_xpk_unpack_txt,a5
  3681.         bsr.w    print_status_middle_new
  3682.         move.l    (SP)+,a5
  3683.  
  3684.         move.l    xpk_master_base,a6
  3685.         lea    xpk_unp_tags,a0
  3686.         move.l    file_hd,4(a0)
  3687.         move.l    a5,12(a0)
  3688.         move.l    file_length,20(a0)        ;output area length!
  3689.         jsr    XpkUnpack(a6)
  3690.         tst.l    d0
  3691.         bne.s    load_file_xpk_argh        ;error here!
  3692.  
  3693.         move.l    dos_base,a6
  3694.         move.l    file_hd,d1
  3695.         jsr    Close(a6)
  3696.         moveq.l    #0,d0
  3697.         rts
  3698.  
  3699. load_file_xpk_argh:
  3700.         move.l    dos_base,a6
  3701.         move.l    file_hd,d1
  3702.         jsr    Close(a6)
  3703.  
  3704.         bra.w    load_file_error
  3705.  
  3706. load_file_quit_xpk_e:
  3707.         move.l    xpk_master_base,a6        ;an error occurred!
  3708.         move.l    xfh_pointer,a0
  3709.         jsr    XpkClose(a6)
  3710.  
  3711.         bra.w    load_file_error
  3712.  
  3713. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3714. ;        normal dos open and loading
  3715. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3716.  
  3717. load_file_quit_xpk:
  3718.         move.l    xpk_master_base,a6
  3719.         move.l    xfh_pointer,a0            ;it was not packed.
  3720.         jsr    XpkClose(a6)
  3721.  
  3722. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3723. ;        now load the file
  3724. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3725.  
  3726. load_file_no_xpk_open:
  3727.         move.l    dos_base,a6
  3728.         move.l    dir_n_name_ptr,d1
  3729.         move.l    #MODE_OLDFILE,d2
  3730.         jsr    Open(a6)
  3731.         move.l    d0,file_hd
  3732.         beq.w    load_file_error
  3733.  
  3734.         move.l    d0,d1
  3735.         move.l    a5,d2
  3736.         move.l    d7,d3
  3737.         jsr    Read(a6)
  3738.  
  3739.         move.l    file_hd,d1
  3740.         jsr    Close(a6)
  3741.         moveq.l    #0,d0
  3742.         rts
  3743.  
  3744. load_file_error:moveq.l    #1,d0                ;error!
  3745.         rts
  3746.  
  3747. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3748. ;        menu misc about
  3749. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3750.  
  3751. menu_misc_about:bsr.w    function_window_output
  3752.         tst.l    d0
  3753.         beq.w    get_message
  3754.  
  3755.         cmp.l    #"ABOU",function_status
  3756.         beq.w    get_message            ;don't output this twice.
  3757.  
  3758.         bsr.w    gadgets_rmv
  3759.  
  3760.         move.l    graphics_base,a6
  3761.         move.l    about_map_attr,a0        ;a0 = source bitmap.
  3762.         move.l    function_ptr,a1
  3763.         move.l    wd_RPort(a1),a1            ;a1 = destination rastport.
  3764.         moveq.l    #0,d0                ;org x.
  3765.         moveq.l    #0,d1                ;org y.
  3766.         moveq.l    #0,d2                ;dst x.
  3767.         moveq.l    #0,d3                ;dst y.
  3768.         move.l    #function_x_bm,d4        ;size x.
  3769.         move.l    #function_y_bm,d5        ;size y.
  3770.         move.l    #$c0,d6                ;minterm.
  3771.         jsr    BltBitMapRastPort(a6)        ;update the screen window.
  3772.  
  3773.         lea    about_text_1,a0
  3774.         bsr.w    print_middle
  3775.  
  3776.         lea    about_text_2,a0
  3777.         bsr.w    print_middle
  3778.  
  3779.         lea    about_win_txt,a1
  3780.         bsr.w    change_win_title
  3781.  
  3782.         move.l    #"ABOU",function_status
  3783.         bra.w    get_message
  3784.  
  3785. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3786. ;        menu edit gfx
  3787. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3788.  
  3789. menu_edit_gfx:    bsr.b    menu_edit_gfx_on
  3790.         tst.l    d0
  3791.         beq.w    get_message
  3792.  
  3793.         bsr.w    gfx_values_update        ;has .prefs loading altered
  3794.                             ;any gadget values?
  3795.         bra.w    get_message
  3796.  
  3797. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3798. ;        menu edit gfx
  3799. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3800.  
  3801. menu_edit_gfx_on:
  3802.         bsr.w    function_window_output
  3803.         tst.l    d0
  3804.         beq.w    menu_edit_gfx_on_exit
  3805.  
  3806.         moveq.l    #1,d0
  3807.         cmp.l    #"GFX!",function_status
  3808.         beq.w    menu_edit_gfx_on_exit        ;don't output this twice.
  3809.  
  3810.         bsr.w    gadgets_rmv
  3811.         bsr.w    back_pattern_function
  3812.  
  3813.         move.l    function_ptr,a4
  3814.         lea    gfx_bevel_list,a5
  3815.         bsr.w    draw_bevel_list
  3816.  
  3817.         move.l    context_g_gfx,a1
  3818.         move.l    (a1),a1
  3819.         bsr.w    gadgets_ins
  3820.  
  3821.         move.l    #gfx_jmp_table,function_jmp
  3822.         move.l    #"GFX!",function_status
  3823.  
  3824.         bsr.w    gfx_values_update        ;has .prefs loading altered
  3825.                             ;any gadget values?
  3826.         bsr.w    obtain_status_direct        ;turn it on/off?
  3827.  
  3828.         bsr.w    write_test_image
  3829.  
  3830.         move.l    intuition_base,a6
  3831.         move.l    function_ptr,a0
  3832.         move.l    wd_RPort(a0),a0
  3833.         lea    gfx_txt_1,a1
  3834.         moveq.l    #0,d0
  3835.         moveq.l    #0,d1
  3836.         jsr    PrintIText(a6)
  3837.  
  3838.         lea    gfx_win_txt,a1
  3839.         bsr.w    change_win_title
  3840.  
  3841. menu_edit_gfx_on_exit:
  3842.         rts
  3843.  
  3844. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3845. ;        menu edit sfx
  3846. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3847.  
  3848. menu_edit_sfx:
  3849.  
  3850.         bsr.w    function_window_output
  3851.         tst.l    d0
  3852.         beq.w    get_message
  3853.  
  3854.         cmp.l    #"SFX!",function_status
  3855.         beq.w    get_message            ;don't output this twice.
  3856.  
  3857.         bsr.w    gadgets_rmv
  3858.         bsr.w    back_pattern_function
  3859.  
  3860.         move.l    ahi_mode_txt,sfx_ahi_txt    ;install the pointer.
  3861.  
  3862.         move.l    function_ptr,a4
  3863.         lea    sfx_bevel_list,a5
  3864.         bsr.w    draw_bevel_list
  3865.  
  3866.         move.l    context_g_sfx,a1
  3867.         move.l    (a1),a1
  3868.         bsr.w    gadgets_ins
  3869.  
  3870.         move.l    sfx_g_y_hz,a0
  3871.         lea    alter_tags_slider,a3
  3872.         move.b    sfx_y_update,d0
  3873.         bsr.w    set_gadget_attributes
  3874.  
  3875.         move.l    intuition_base,a6
  3876.         move.l    function_ptr,a0
  3877.         move.l    wd_RPort(a0),a0
  3878.         lea    sfx_c_1_text,a1
  3879.         moveq.l    #0,d0
  3880.         moveq.l    #0,d1
  3881.         jsr    PrintIText(a6)
  3882.  
  3883.         move.l    #sfx_jmp_table,function_jmp
  3884.         move.l    #"SFX!",function_status
  3885.  
  3886.         lea    sfx_win_txt,a1
  3887.         bsr.w    change_win_title
  3888.  
  3889. ahi_is_in_system:
  3890.         move.l    ahi_mode_id,d0
  3891.         bra.w    ahi_mode_info            ;print the text ->
  3892.                             ;get_message.
  3893. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3894. ;        obtain new colours from wzonka-lad
  3895. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3896.  
  3897. obtain_from_colour_editor:
  3898.         move.l    exec_base,a6
  3899.         jsr    Forbid(a6)
  3900.  
  3901.         lea    message_port_colour_editor_name,a1
  3902.         jsr    FindPort(a6)
  3903.         move.l    d0,message_port_colour_editor
  3904.         jsr    Permit(a6)
  3905.  
  3906.         tst.l    message_port_colour_editor
  3907.         beq.w    get_message
  3908.  
  3909.         move.l    exec_base,a6
  3910.         move.l    message_port_colour_editor,a0
  3911.         move.l    colour_message,a1
  3912.         move.l    colour_message_name,a2
  3913.         move.b    #1,(a2)                ;request for the colours.
  3914.         jsr    PutMsg(a6)
  3915.  
  3916.         move.l    message_port,a0
  3917.         jsr    WaitPort(a6)
  3918.  
  3919.         bsr.w    obtain_status_on_get_message
  3920.         bra.w    get_message
  3921.  
  3922. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3923. ;        select a new screen mode
  3924. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3925.  
  3926. get_gfx_screen_mode:
  3927.         move.l    req_tools_base,a6
  3928.         move.l    request_ptr_sm,a1        ;requester.
  3929.         lea    request_smode,a3        ;requester title.
  3930.         lea    req_smode_tags,a0        ;requester tags.
  3931.         jsr    rtScreenModeRequestA(a6)    ;ask for screen mode.
  3932.         cmp.l    #FALSE,d0            ;cancelled?
  3933.         beq.s    no_mode                ;yes. use default.
  3934.  
  3935.         move.l    request_ptr_sm,a0
  3936.         move.l    rtsc_DisplayID(a0),d7        ;take the new screen id.
  3937.         cmp.l    gb_screen_id+4,d7
  3938.         beq.s    no_mode
  3939.         move.l    d7,gb_screen_id+4
  3940.  
  3941.         bsr.b    close_graphics
  3942.  
  3943.         bsr.w    allocate_gfx_driver_memory
  3944.         tst.l    d0                ;errors?
  3945.         bne.w    quit                ;yes! quit!
  3946.  
  3947. no_mode:    bra.w    get_message
  3948.  
  3949. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3950. ;        get gfx driver button value
  3951. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3952.  
  3953. get_gfx_driver:    move.l    gfx_g_driver,a0
  3954.         bsr.w    get_mx
  3955.  
  3956.         cmp.b    old_render,d0
  3957.         beq.w    get_message            ;it's the same.
  3958.  
  3959.         move.b    d0,old_render
  3960.  
  3961. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3962. ;        free old driver option vectors and allocate new ones
  3963. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3964.  
  3965.         bsr.b    close_graphics
  3966.  
  3967.         bsr.w    allocate_gfx_driver_memory
  3968.         tst.l    d0                ;errors?
  3969.         bne.w    quit                ;yes! quit!
  3970.  
  3971.         bra.w    get_message
  3972.  
  3973. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3974. ;        close graphics
  3975. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3976.  
  3977. close_graphics:    bsr.b    close_and_free_aga
  3978.         bsr.b    close_and_free_screen
  3979.         bsr.b    close_and_free_window
  3980.         rts
  3981.  
  3982. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3983. ;        close graphics driver output and free the vectors
  3984. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3985.  
  3986. close_and_free_aga:
  3987.         lea    list_aga,a5
  3988.         bsr.w    free_vectors            ;free the allocated memory.
  3989.         rts
  3990. close_and_free_screen:
  3991.         bsr.w    dbuf_dealloc
  3992.  
  3993.         lea    list_screen,a5
  3994.         bsr.w    free_vectors            ;free the allocated memory.
  3995.         rts
  3996. close_and_free_window:
  3997.         lea    list_window,a5
  3998.         bsr.w    free_vectors            ;free the allocated memory.
  3999.  
  4000.         lea    wzonka_ptr,a5
  4001.         lea    wzonka_window,a4
  4002.         tst.l    (a5)
  4003.         beq.s    close_and_free_window_no_window
  4004.         move.l    (a5),a0
  4005.         move.w    wd_LeftEdge(a0),nw_LeftEdge(a4)
  4006.         move.w    wd_TopEdge(a0),nw_TopEdge(a4)
  4007.         tst.b    scaling_status
  4008.         beq.s    close_and_free_window_fixed
  4009.         move.w    wd_Width(a0),wzonka_window_x
  4010.         move.w    wd_Height(a0),wzonka_window_y
  4011. close_and_free_window_fixed:
  4012.         bsr.w    close_window
  4013.  
  4014. close_and_free_window_no_window:
  4015.         lea    game_tmp_map_attr,a1
  4016.         bsr.w    free_bit_maps
  4017.         lea    game_output_tmp_map_attr,a1
  4018.         bsr.w    free_bit_maps
  4019.         rts
  4020.  
  4021. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4022. ;        allocate gfx driver memory
  4023. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4024.  
  4025. allocate_gfx_driver_memory:
  4026.         move.b    old_render,d0
  4027.         beq.s    allocate_aga
  4028.         cmp.b    #1,d0
  4029.         beq.s    allocate_screen
  4030.         cmp.b    #2,d0
  4031.         beq.s    allocate_window
  4032.         moveq.l    #0,d0
  4033.         rts
  4034.  
  4035. allocate_aga:    tst.b    aga_status
  4036.         beq.s    allocate_gfx_driver_memory_exit    ;no aga available.
  4037.  
  4038.         lea    list_aga_structure,a4
  4039.         lea    list_aga,a5
  4040.         bsr.w    allocate_list            ;allocate memory.
  4041.         tst.l    d0                ;errors?
  4042.         beq.w    allocate_gfx_driver_memory_error;yes! quit!
  4043.  
  4044.         bsr.w    create_coppers            ;create the copper list
  4045.                             ;for aga h/w modes.
  4046. allocate_gfx_driver_memory_exit:
  4047.         moveq.l    #0,d0
  4048.         rts
  4049.  
  4050. allocate_screen:move.l    #MEMF_CHIP!MEMF_CLEAR,screen_chip_1+8
  4051.         move.l    #MEMF_CHIP!MEMF_CLEAR,screen_chip_2+8
  4052.  
  4053.         tst.b    fast_ram_bitmaps
  4054.         beq.s    allocate_screen_in_chip
  4055.  
  4056.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,screen_chip_1+8
  4057.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,screen_chip_2+8
  4058.  
  4059. allocate_screen_in_chip:
  4060.         lea    list_screen_structure,a4
  4061.         lea    list_screen,a5
  4062.         bsr.w    allocate_list            ;allocate memory.
  4063.         tst.l    d0                ;errors?
  4064.         beq.w    allocate_gfx_driver_memory_error;yes! quit!
  4065.  
  4066.         bsr.w    dbuf_alloc
  4067.  
  4068.         moveq.l    #0,d0
  4069.         rts
  4070.  
  4071. allocate_window:move.l    #MEMF_CHIP!MEMF_CLEAR,window_chip_1+8
  4072.  
  4073.         tst.b    fast_ram_bitmaps
  4074.         beq.s    allocate_window_in_chip
  4075.  
  4076.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,window_chip_1+8
  4077.  
  4078. allocate_window_in_chip:
  4079.         lea    wzonka_window,a0
  4080.         move.l    #160,d0
  4081.         add.l    window_bars_width,d0
  4082.         move.w    d0,nw_Width(a0)
  4083.         move.l    #144,d0
  4084.         add.l    window_bars_height,d0
  4085.         move.w    d0,nw_Height(a0)
  4086.         tst.b    scaling_status
  4087.         beq.s    allocate_window_solid
  4088.         move.w    wzonka_window_x,nw_Width(a0)
  4089.         move.w    wzonka_window_y,nw_Height(a0)
  4090.  
  4091. allocate_window_solid:
  4092.         lea    list_window_structure,a4
  4093.         lea    list_window,a5
  4094.         bsr.w    allocate_list            ;allocate memory.
  4095.         tst.l    d0                ;errors?
  4096.         beq.s    allocate_gfx_driver_memory_error;yes! quit!
  4097.  
  4098.         move.l    intuition_base,a6
  4099.         lea    wzonka_window,a0
  4100.         lea    win_tags_u,a1            ;universal taglist.
  4101.         jsr    OpenWindowTagList(a6)        ;structure and open the window.
  4102.         move.l    d0,wzonka_ptr
  4103.         beq.w    allocate_gfx_driver_memory_error
  4104.  
  4105.         bsr.b    compute_wzonka_window_values
  4106.         tst.l    d0
  4107.         beq.w    allocate_window
  4108.  
  4109.         tst.b    old_refresh            ;mode 144/144?
  4110.         beq.s    change_160x144            ;yes.        
  4111. change_176x152:    bsr.w    init_wzonka_176
  4112.         moveq.l    #0,d0
  4113.         rts
  4114. change_160x144:    bsr.w    init_wzonka_160
  4115.         moveq.l    #0,d0
  4116.         rts
  4117.  
  4118. allocate_gfx_driver_memory_error:
  4119.         moveq.l    #1,d0
  4120.         rts
  4121.  
  4122. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4123. ;        compute wzonka window values
  4124. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4125.  
  4126. compute_wzonka_window_values:
  4127.         move.l    #wd_Width,d1
  4128.         move.l    window_bars_width,d2
  4129.         tst.b    scaling_status
  4130.         beq.s    compute_wzonka_window_values_no_x_fix
  4131.         add.l    #window_right_bar_x,d2
  4132. compute_wzonka_window_values_no_x_fix:
  4133.         lea    wzonka_window_title_x,a0
  4134.         lea    wzonka_game_x,a6
  4135.         clr.b    d7
  4136.         bsr.w    reformat_wzonka_window_values
  4137.         tst.l    d1
  4138.         bne.s    compute_wzonka_window_values_no_recompute
  4139.  
  4140.         movem.l    d0/d3,-(SP)
  4141.         bsr.w    close_and_free_window
  4142.         movem.l    (SP)+,d0/d3
  4143.  
  4144.         and.l    #%1111,d0
  4145.         and.l    #$0000ffff,d3
  4146.         sub.l    d0,d3
  4147.         move.w    d3,wzonka_window_x
  4148.  
  4149.         moveq.l    #0,d0
  4150.         rts
  4151.  
  4152. compute_wzonka_window_values_no_recompute:
  4153.         move.l    #wd_Height,d1
  4154.         move.l    window_bars_height,d2
  4155.         lea    wzonka_window_title_y,a0
  4156.         lea    wzonka_game_y,a6
  4157.         move.b    #1,d7
  4158.         bsr.b    reformat_wzonka_window_values
  4159.  
  4160.         move.l    wzonka_ptr,d0
  4161.         beq.s    compute_wzonka_window_values_exit
  4162.         move.l    d0,a0
  4163.         lea    wzonka_window_title_txt,a1
  4164.         lea    wzonka_window_screen_txt,a2
  4165.         move.l    intuition_base,a6
  4166.         jsr    SetWindowTitles(a6)
  4167. compute_wzonka_window_values_exit:
  4168.         moveq.l    #1,d0
  4169.         rts
  4170.  
  4171. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4172. ;        reformat a value between 0 and 999
  4173. ;        INPUT:
  4174. ;        d1    = adder.
  4175. ;        d2    = subber.
  4176. ;        d7    = 0 = size check / 1 = no size check.
  4177. ;        a0    = output.
  4178. ;        a6    = pointer to a .L where the size will be held.
  4179. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4180.  
  4181. reformat_wzonka_window_values:
  4182.         moveq.l    #0,d0
  4183.         move.l    wzonka_ptr,d4
  4184.         beq.s    reformat_wzonka_window_values_exit
  4185.         move.l    d4,a5
  4186.         move.w    (a5,d1.l),d0
  4187.         move.l    d0,d3
  4188.         sub.l    d2,d0
  4189.         move.l    d0,(a6)
  4190.         tst.b    d7
  4191.         bne.s    reformat_wzonka_window_values_no_size_check
  4192.  
  4193.         move.b    d0,d1
  4194.         and.b    #%1111,d1
  4195.         bne.s    reformat_wzonka_window_values_recompute
  4196.  
  4197. reformat_wzonka_window_values_no_size_check:
  4198.         divu.w    #100,d0
  4199.         add.b    #"0",d0
  4200.         move.b    d0,(a0)+
  4201.         clr.w    d0
  4202.         swap    d0
  4203.         divu.w    #10,d0
  4204.         add.b    #"0",d0
  4205.         move.b    d0,(a0)+
  4206.         swap    d0
  4207.         add.b    #"0",d0
  4208.         move.b    d0,(a0)
  4209. reformat_wzonka_window_values_exit:
  4210.         moveq.l    #1,d1
  4211.         rts
  4212. reformat_wzonka_window_values_recompute:
  4213.         moveq.l    #0,d1
  4214.         rts
  4215.  
  4216. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4217. ;        get wzonka game window scaled dimensions
  4218. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4219.  
  4220. get_wzonka_window_scaled_dimensions:
  4221.         move.l    wzonka_ptr,d1
  4222.         beq.s    get_wzonka_window_scaled_dimensions_no_window
  4223.         tst.b    scaling_status
  4224.         beq.s    get_wzonka_window_scaled_dimensions_not_scalable
  4225.         move.l    d1,a0
  4226.         move.w    wd_Width(a0),wzonka_window_x
  4227.         move.w    wd_Height(a0),wzonka_window_y
  4228. get_wzonka_window_scaled_dimensions_no_window:
  4229. get_wzonka_window_scaled_dimensions_not_scalable:
  4230.         rts
  4231.  
  4232. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4233. ;        get gfx scaling button value
  4234. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4235.  
  4236. get_gfx_scaling:move.l    gfx_g_scaling,a0
  4237.         bsr.w    get_mx
  4238.  
  4239.         move.l    d0,-(SP)
  4240.         bsr.b    get_wzonka_window_scaled_dimensions
  4241.         bsr.w    close_and_free_window
  4242.         move.l    (SP)+,d0
  4243.         move.b    d0,scaling_status
  4244.  
  4245.         bsr.w    get_wzonka_window_flags
  4246.         bsr.w    allocate_gfx_driver_memory
  4247.  
  4248.         bra.w    get_message
  4249.  
  4250. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4251. ;        get gfx mode button value
  4252. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4253.  
  4254. get_gfx_mode:    move.l    gfx_g_mode,a0
  4255.         bsr.w    get_mx
  4256.  
  4257.         move.l    d0,-(SP)
  4258.         bsr.w    close_graphics
  4259.         move.l    (SP)+,d0
  4260.  
  4261.         move.b    d0,old_refresh
  4262.         bsr.w    allocate_gfx_driver_memory
  4263.  
  4264.         bra.w    get_message
  4265.  
  4266. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4267. ;        get x slider value
  4268. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4269.  
  4270. get_gfx_x:    move.l    gfx_g_scanline_x,a0
  4271.         bsr.w    get_slider
  4272.  
  4273.         move.b    d0,refresh_scanline
  4274.  
  4275.         bra.w    get_message
  4276.  
  4277. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4278. ;        get x slider value
  4279. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4280.  
  4281. get_gfx_colour_status:
  4282.         move.l    gfx_g_colour_load,a0
  4283.         bsr.w    get_checkbox
  4284.  
  4285.         move.b    d0,colour_load_status
  4286.  
  4287.         bra.w    get_message
  4288.  
  4289. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4290. ;        get gfx aga mode button value
  4291. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4292.  
  4293. get_gfx_aga_mode:
  4294.         move.l    gfx_g_aga_mode,a0
  4295.         bsr.w    get_mx
  4296.  
  4297.         move.b    d0,aga_mode
  4298.  
  4299.         bra.w    get_message
  4300.  
  4301. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4302. ;        get frame skip slider value
  4303. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4304.  
  4305. get_gfx_frame_skip:
  4306.         move.l    gfx_g_frame_skip,a0
  4307.         bsr.w    get_slider
  4308.  
  4309.         move.b    d0,frame_update_number
  4310.         addq.b    #1,d0
  4311.         move.b    d0,frame_update
  4312.  
  4313.         bra.w    get_message
  4314.  
  4315. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4316. ;        window button jump tables
  4317. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4318.  
  4319. gfx_jmp_table:    dc.l    get_gfx_driver
  4320.         dc.l    get_gfx_scaling
  4321.         dc.l    get_gfx_mode
  4322.         dc.l    get_gfx_x
  4323.         dc.l    get_gfx_screen_mode
  4324.         dc.l    get_gfx_aga_mode
  4325.         dc.l    obtain_from_colour_editor
  4326.         dc.l    get_gfx_frame_skip
  4327.         dc.l    get_gfx_colour_status
  4328.  
  4329. prefs_jmp_table:dc.l    get_prefs_str_1
  4330.         dc.l    get_prefs_str_2
  4331.         dc.l    get_prefs_str_3
  4332.         dc.l    get_prefs_str_4
  4333.         dc.l    get_prefs_dir_1
  4334.         dc.l    get_prefs_dir_2
  4335.         dc.l    get_prefs_dir_3
  4336.         dc.l    get_prefs_dir_4
  4337.         dc.l    get_prefs_xpk
  4338.         dc.l    get_prefs_battery_xpk
  4339.         dc.l    get_prefs_gbs
  4340.         dc.l    get_prefs_joy
  4341.         dc.l    prefs_save_default
  4342.         dc.l    get_prefs_battery
  4343.         dc.l    save_prefs
  4344.  
  4345.  
  4346. sfx_jmp_table:    dc.l    sfx_jmp_audio
  4347.         dc.l    sfx_jmp_quality
  4348.         dc.l    sfx_jmp_c1
  4349.         dc.l    sfx_jmp_c2
  4350.         dc.l    sfx_jmp_c3
  4351.         dc.l    sfx_jmp_c4
  4352.         dc.l    sfx_jmp_ahi
  4353.         dc.l    sfx_jmp_y
  4354.         dc.l    sfx_jmp_volume
  4355.  
  4356. misc_jmp_table:    dc.l    misc_forbid_permit
  4357.         dc.l    misc_os_screen_speed_limit
  4358.         dc.l    misc_patch
  4359.         dc.l    get_message
  4360.         dc.l    get_message
  4361.         dc.l    get_message
  4362.         dc.l    misc_fast_ram_bitmaps
  4363.         dc.l    misc_get_gg
  4364.  
  4365. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4366. ;        get a new patch code
  4367. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4368.  
  4369. misc_get_gg:    move.l    misc_b_code_list,a0
  4370.         bsr.w    get_listview
  4371.  
  4372.         move.b    d0,misc_b_code_list_selected
  4373.  
  4374.         move.b    gg_code_status,d1
  4375.         beq.s    misc_get_gg_reg
  4376.         cmp.b    #1,d1
  4377.         beq.s    misc_get_gg_real_code
  4378.         bra.w    get_message            ;none.
  4379.  
  4380. misc_get_gg_reg:bsr.b    set_gg_strs            ;reg-ist-er!
  4381.         bra.w    get_message
  4382.  
  4383. misc_get_gg_real_code:
  4384.         moveq.l    #0,d1                ;the list.
  4385.         move.l    gg_linked_list,a0
  4386.  
  4387. misc_get_gg_real_code_loop:
  4388.         cmp.b    d0,d1
  4389.         beq.s    misc_get_gg_real_code_found
  4390.         addq.b    #1,d1
  4391.         move.l    (a0),a0
  4392.         bra.s    misc_get_gg_real_code_loop
  4393.  
  4394. misc_get_gg_real_code_found:
  4395.         add.l    #12,a0
  4396.         move.l    (a0),gg_register_1_txt
  4397.         clr.b    gg_register_1_txt+3
  4398.         move.l    4(a0),gg_register_2_txt
  4399.         clr.b    gg_register_2_txt+3
  4400.         move.l    8(a0),gg_register_3_txt
  4401.         clr.b    gg_register_3_txt+3
  4402.  
  4403.         bsr.b    set_gg_strs
  4404.         bra.w    get_message
  4405.  
  4406. set_gg_strs:    move.l    misc_b_str_1,a0            ;get the gadget.
  4407.         move.l    #gg_register_1_txt,d0
  4408.         bsr.b    set_gg_str_slot
  4409.  
  4410.         move.l    misc_b_str_2,a0            ;get the gadget.
  4411.         move.l    #gg_register_2_txt,d0
  4412.         bsr.b    set_gg_str_slot
  4413.  
  4414.         move.l    misc_b_str_3,a0            ;get the gadget.
  4415.         move.l    #gg_register_3_txt,d0
  4416.         bsr.b    set_gg_str_slot
  4417.         rts
  4418.  
  4419. set_gg_str_slot:move.l    gad_tools_base,a6
  4420.         move.l    function_ptr,a1
  4421.         sub.l    a2,a2
  4422.         lea    prefs_g_str_chg,a3
  4423.         move.l    d0,4(a3)
  4424.         jsr    GT_SetGadgetAttrsA(a6)        ;set the new text.
  4425.         rts
  4426.  
  4427. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4428. ;        patch the rom!!!
  4429. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4430.  
  4431. misc_patch:    tst.l    cartridge
  4432.         beq.w    misc_patch_none
  4433.  
  4434.         lea    gg_patch,a5
  4435.  
  4436.         move.l    gad_tools_base,a6
  4437.         move.l    misc_b_str_1,a0
  4438.         move.l    function_ptr,a1
  4439.         sub.l    a2,a2
  4440.         lea    prefs_g_str_chg,a3
  4441.         move.l    #prefs_str_ptr,4(a3)
  4442.         jsr    GT_GetGadgetAttrsA(a6)
  4443.         move.l    prefs_str_ptr,a0
  4444.         move.w    (a0)+,(a5)+
  4445.         move.b    (a0),(a5)+
  4446.  
  4447.         move.l    misc_b_str_2,a0
  4448.         move.l    function_ptr,a1
  4449.         sub.l    a2,a2
  4450.         lea    prefs_g_str_chg,a3
  4451.         move.l    #prefs_str_ptr,4(a3)
  4452.         jsr    GT_GetGadgetAttrsA(a6)
  4453.         move.l    prefs_str_ptr,a0
  4454.         move.w    (a0)+,(a5)+
  4455.         move.b    (a0),(a5)+
  4456.  
  4457.         move.l    misc_b_str_3,a0
  4458.         move.l    function_ptr,a1
  4459.         sub.l    a2,a2
  4460.         lea    prefs_g_str_chg,a3
  4461.         move.l    #prefs_str_ptr,4(a3)
  4462.         jsr    GT_GetGadgetAttrsA(a6)
  4463.         move.l    prefs_str_ptr,a0
  4464.         move.w    (a0)+,(a5)+
  4465.         move.b    (a0),(a5)
  4466.  
  4467.         bsr.w    decode_gg_patch
  4468.         tst.l    d6
  4469.         bne.s    gg_patch_invalid_code
  4470.  
  4471.         move.l    cartridge,a0
  4472.         moveq.l    #1,d3
  4473.         moveq.l    #1,d4
  4474.         add.b    $148(a0),d3
  4475.         lsl.w    d3,d4
  4476.         subq.w    #1,d4
  4477.         moveq.l    #0,d7
  4478.  
  4479. gg_patch_rom:    lea    (a0,d1.l),a1
  4480.         cmp.b    (a1),d2
  4481.         bne.s    gg_patch_rom_miss
  4482.         move.b    d0,(a1)
  4483.         addq.b    #1,d7
  4484. gg_patch_rom_miss:
  4485.         add.l    #$8000,a0
  4486.         dbra    d4,gg_patch_rom
  4487.  
  4488.         tst.b    d7
  4489.         beq.s    gg_patch_none
  4490.  
  4491.         bsr.w    gg_patch_apply
  4492.  
  4493.         lea    status_rom_patched_txt,a5
  4494.         bsr.w    print_status_middle
  4495.         bra.w    get_message
  4496.  
  4497. gg_patch_none:    lea    status_patch_none_txt,a5
  4498.         bsr.w    print_status_middle
  4499.         bra.w    get_message
  4500.  
  4501. gg_patch_invalid_code:
  4502.         lea    status_invalid_patch_txt,a5
  4503.         bsr.w    print_status_middle
  4504.         bra.w    get_message
  4505.  
  4506. misc_patch_none:lea    status_no_rom_txt,a5
  4507.         bsr.w    print_status_middle
  4508.         bra.w    get_message
  4509.  
  4510. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4511. ;        get misc forbid/permit checkbox value
  4512. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4513.  
  4514. misc_forbid_permit:
  4515.         move.l    misc_b_1,a0
  4516.         bsr.w    get_checkbox
  4517.  
  4518.         move.b    d0,forbid_permit_status
  4519.  
  4520.         bra.w    get_message
  4521.  
  4522. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4523. ;        get misc os screen speed limit checkbox value
  4524. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4525.  
  4526. misc_os_screen_speed_limit:
  4527.         move.l    misc_b_2,a0
  4528.         bsr.w    get_checkbox
  4529.  
  4530.         move.b    d0,os_screen_speed_limit
  4531.  
  4532.         bra.w    get_message
  4533.  
  4534. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4535. ;        get misc fast ram bitmaps checkbox value
  4536. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4537.  
  4538. misc_fast_ram_bitmaps:
  4539.         move.l    misc_b_6,a0
  4540.         bsr.w    get_checkbox
  4541.  
  4542.         move.b    d0,fast_ram_bitmaps
  4543.  
  4544.         bsr.w    close_graphics
  4545.  
  4546.         bsr.w    allocate_gfx_driver_memory
  4547.         tst.l    d0
  4548.         bne.w    quit
  4549.  
  4550.         bra.w    get_message
  4551.  
  4552. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4553. ;        get prefs battery button value
  4554. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4555.  
  4556. get_prefs_battery:
  4557.         move.l    prefs_g_battery_status,a0
  4558.         bsr.w    get_mx
  4559.  
  4560.         move.b    d0,battery_status
  4561.  
  4562.         bra.w    get_message
  4563.  
  4564. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4565. ;        get prefs battery xpk button value
  4566. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4567.  
  4568. get_prefs_battery_xpk:
  4569.         move.l    prefs_g_battery,a0
  4570.         bsr.w    get_mx
  4571.  
  4572.         move.b    d0,battery_xpk_status
  4573.  
  4574.         bra.w    get_message
  4575.  
  4576. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4577. ;        get xpk listview value
  4578. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4579.  
  4580. get_prefs_xpk:    move.l    prefs_g_xpk,a0
  4581.         bsr.w    get_listview
  4582.  
  4583.         move.l    xpk_names,a0
  4584.         move.l    (a0,d0.l*4),pck_method
  4585.         move.b    d0,pck_method_number
  4586.  
  4587.         bra.w    get_message
  4588.  
  4589. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4590. ;        get gbs mx value
  4591. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4592.  
  4593. get_prefs_gbs:    move.l    prefs_g_gbs,a0
  4594.         bsr.w    get_mx
  4595.  
  4596.         move.b    d0,pck_xpk_status
  4597.  
  4598.         bra.w    get_message
  4599.  
  4600. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4601. ;        get controller listview value
  4602. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4603.  
  4604. get_prefs_joy:    move.l    prefs_g_joy,a0
  4605.         bsr.w    get_listview
  4606.  
  4607.         move.b    d0,keystick
  4608.  
  4609.         bra.w    get_message
  4610.  
  4611.  
  4612. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4613. ;        sound preferences - audio on/off
  4614. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4615.  
  4616. sfx_jmp_audio:    move.l    sfx_g_audio,a0
  4617.         bsr.w    get_checkbox
  4618.  
  4619.         bchg    #0,d0
  4620.         move.b    d0,snd_master
  4621.  
  4622.         bra.w    get_message
  4623.  
  4624. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4625. ;        sound preferences - quality high/low/y hz
  4626. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4627.  
  4628. sfx_jmp_quality:move.l    sfx_g_quality,a0
  4629.         bsr.w    get_mx
  4630.  
  4631.         move.b    d0,snd_quality
  4632.  
  4633.         bra.w    get_message
  4634.  
  4635. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4636. ;        sound preferences - channel 1 on/off
  4637. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4638.  
  4639. sfx_jmp_c1:    move.l    sfx_g_c_1,a0
  4640.         bsr.b    get_checkbox
  4641.  
  4642.         bchg    #0,d0
  4643.         move.b    d0,snd_chnlI
  4644.  
  4645.         bra.w    get_message
  4646.  
  4647. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4648. ;        sound preferences - channel 2 on/off
  4649. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4650.  
  4651. sfx_jmp_c2:    move.l    sfx_g_c_2,a0
  4652.         bsr.b    get_checkbox
  4653.  
  4654.         bchg    #0,d0
  4655.         move.b    d0,snd_chnlII
  4656.     
  4657.         bra.w    get_message
  4658.  
  4659. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4660. ;        sound preferences - channel 3 on/off
  4661. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4662.  
  4663. sfx_jmp_c3:    move.l    sfx_g_c_3,a0
  4664.         bsr.b    get_checkbox
  4665.  
  4666.         bchg    #0,d0
  4667.         move.b    d0,snd_chnlIII
  4668.  
  4669.         bra.w    get_message
  4670.  
  4671. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4672. ;        sound preferences - channel 4 on/off
  4673. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4674.  
  4675. sfx_jmp_c4:    move.l    sfx_g_c_4,a0
  4676.         bsr.b    get_checkbox
  4677.  
  4678.         bchg    #0,d0
  4679.         move.b    d0,snd_chnlIV
  4680.  
  4681.         bra.w    get_message
  4682.  
  4683. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4684. ;        get y slider value
  4685. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4686.  
  4687. sfx_jmp_y:    move.l    sfx_g_y_hz,a0
  4688.         bsr.w    get_slider
  4689.  
  4690.         move.b    d0,sfx_y_update
  4691.  
  4692.         bra.w    get_message
  4693.  
  4694. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4695. ;        get volume slider value
  4696. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4697.  
  4698. sfx_jmp_volume:    move.l    sfx_g_volume,a0
  4699.         bsr.w    get_slider
  4700.  
  4701.         move.b    d0,sfx_volume_value
  4702.  
  4703.         bsr.w    fix_volume_tables
  4704.  
  4705.         bra.w    get_message
  4706.  
  4707. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4708. ;        get checkbox's value
  4709. ;        INPUT:
  4710. ;        a0    = the checkbox gadget.
  4711. ;        OUTPUT:
  4712. ;        d0    = the value.
  4713. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4714.  
  4715. get_checkbox:    move.l    gad_tools_base,a6
  4716.         move.l    function_ptr,a1
  4717.         sub.l    a2,a2
  4718.         lea    get_checkbox_attr,a3
  4719.         jsr    GT_GetGadgetAttrsA(a6)        ;get the new text.
  4720.  
  4721.         move.l    checkbox_status,d0
  4722.         rts
  4723.  
  4724. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4725. ;        get mx button's value
  4726. ;        INPUT:
  4727. ;        a0    = the mx gadget.
  4728. ;        OUTPUT:
  4729. ;        d0    = the value.
  4730. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4731.  
  4732. get_mx:        move.l    gad_tools_base,a6
  4733.         move.l    function_ptr,a1
  4734.         sub.l    a2,a2
  4735.         lea    get_mx_attr,a3
  4736.         jsr    GT_GetGadgetAttrsA(a6)        ;get the new text.
  4737.  
  4738.         move.l    mx_attr_value,d0
  4739.         rts
  4740.  
  4741. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4742. ;        get slider's value
  4743. ;        INPUT:
  4744. ;        a0    = the slider gadget.
  4745. ;        OUTPUT:
  4746. ;        d0    = the value.
  4747. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4748.  
  4749. get_slider:    move.l    gad_tools_base,a6
  4750.         move.l    function_ptr,a1
  4751.         sub.l    a2,a2
  4752.         lea    get_slider_attr,a3
  4753.         jsr    GT_GetGadgetAttrsA(a6)        ;get the new text.
  4754.  
  4755.         move.l    slider_attr_value,d0
  4756.         rts
  4757.  
  4758. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4759. ;        get listview's value
  4760. ;        INPUT:
  4761. ;        a0    = the listview gadget.
  4762. ;        OUTPUT:
  4763. ;        d0    = the value.
  4764. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4765.  
  4766. get_listview:    move.l    gad_tools_base,a6
  4767.         move.l    function_ptr,a1
  4768.         sub.l    a2,a2
  4769.         lea    get_listview_attr,a3
  4770.         jsr    GT_GetGadgetAttrsA(a6)        ;get the new text.
  4771.  
  4772.         move.l    listview_attr_value,d0
  4773.         rts
  4774.  
  4775. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4776. ;        sound preferences - select AHI mode
  4777. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4778.  
  4779.  
  4780. sfx_jmp_ahi:    move.l    ahi_base,a6
  4781.  
  4782.         move.l    ahi_request,a0
  4783.         lea    ahi_requ_tags,a1
  4784.         move.l    menu_ptr,4(a1)            ;pointer to a window.
  4785.         move.l    ahi_mix_freq,12(a1)        ;old mix freq.
  4786.         move.l    ahi_mode_id,20(a1)        ;old audio id.
  4787.         jsr    AHI_AudioRequestA(a6)
  4788.  
  4789.         cmp.l    #FALSE,d0
  4790.         beq.w    get_message            ;error (close pressed).
  4791.  
  4792.         lea    sfx_ahi_text,a0
  4793.         clr.b    (a0)
  4794.         bsr.w    print_middle
  4795.  
  4796.         move.l    ahi_request,a0
  4797.         lea    ahi_alloc_tags,a1
  4798.  
  4799.         move.l    ahiam_MixFreq(a0),d0
  4800.         move.l    d0,12(a1)
  4801.         move.l    d0,ahi_mix_freq
  4802.  
  4803.         move.l    ahiam_AudioID(a0),d0
  4804.         move.l    d0,4(a1)            ;use selected mode.
  4805.         move.l    d0,ahi_mode_id
  4806.  
  4807. ahi_mode_info:    move.l    ahi_mode_txt,a0
  4808.         moveq.l    #128/4-1,d1
  4809. clr_ahi_txt:    clr.l    (a0)+
  4810.         dbra    d1,clr_ahi_txt
  4811.  
  4812.         move.l    ahi_base,a6
  4813.         lea    ahi_attrs_tags,a1
  4814.         move.l    ahi_mode_txt,4(a1)
  4815.         jsr    AHI_GetAudioAttrsA(a6)
  4816.  
  4817.         move.l    ahi_mode_txt,a0
  4818.         moveq.l    #128-1,d0
  4819. search_txt_end:    tst.b    (a0)+
  4820.         beq.s    search_txt_x
  4821.         dbra    d0,search_txt_end
  4822.  
  4823. search_txt_x:    subq.l    #1,a0                ;output the frequency.
  4824.         move.w    #" (",(a0)+
  4825.         move.l    ahi_mix_freq,d0
  4826.  
  4827.         move.l    d0,d1
  4828.         divu.l    #1000000,d1
  4829.         beq.s    search_txt_qqq
  4830.         add.b    #48,d1
  4831.         move.b    d1,(a0)+
  4832.         sub.b    #48,d1
  4833.         mulu.l    #1000000,d1
  4834.         sub.l    d1,d0
  4835. search_txt_qqq:    move.l    d0,d1
  4836.         divu.l    #100000,d1
  4837.         beq.s    search_txt_qq
  4838.         add.b    #48,d1
  4839.         move.b    d1,(a0)+
  4840.         sub.b    #48,d1
  4841.         mulu.l    #100000,d1
  4842.         sub.l    d1,d0
  4843. search_txt_qq:    divu.w    #10000,d0
  4844.         beq.s    search_txt_q
  4845.         add.b    #48,d0
  4846.         move.b    d0,(a0)+
  4847.         clr.w    d0
  4848. search_txt_q:    swap    d0
  4849.         divu.w    #1000,d0
  4850.         add.b    #48,d0
  4851.         move.b    d0,(a0)+
  4852.         clr.w    d0
  4853.         swap    d0
  4854.         divu.w    #100,d0
  4855.         add.b    #48,d0
  4856.         move.b    d0,(a0)+
  4857.         clr.w    d0
  4858.         swap    d0
  4859.         divu.w    #10,d0
  4860.         add.b    #48,d0
  4861.         move.b    d0,(a0)+
  4862.         swap    d0
  4863.         add.b    #48,d0
  4864.         move.b    d0,(a0)+
  4865.         move.l    #" Hz)",(a0)+
  4866.         clr.b    (a0)
  4867.  
  4868.         lea    sfx_ahi_text,a0
  4869.         move.b    #1,(a0)
  4870.         bsr.w    print_middle
  4871.  
  4872.         bra.w    get_message
  4873.  
  4874. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4875. ;        menu edit misc
  4876. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4877.  
  4878. menu_edit_misc:    bsr.w    function_window_output
  4879.         tst.l    d0
  4880.         beq.w    get_message
  4881.  
  4882.         cmp.l    #"MISC",function_status
  4883.         beq.w    get_message            ;don't output this twice.
  4884.  
  4885.         bsr.w    gadgets_rmv
  4886.         bsr.w    back_pattern_function
  4887.  
  4888.         move.l    function_ptr,a4
  4889.         lea    misc_bevel_list,a5
  4890.         bsr.w    draw_bevel_list
  4891.  
  4892.         move.l    context_g_misc,a1
  4893.         move.l    (a1),a1
  4894.         bsr.w    gadgets_ins
  4895.  
  4896.         move.l    gad_tools_base,a6
  4897.         move.l    misc_b_code_list,a0
  4898.         move.l    function_ptr,a1
  4899.         sub.l    a2,a2
  4900.         lea    misc_b_code_list_change_tags,a3
  4901.         move.l    gg_label_list,4(a3)
  4902.         jsr    GT_SetGadgetAttrsA(a6)
  4903.  
  4904.         move.l    intuition_base,a6
  4905.         move.l    function_ptr,a0
  4906.         move.l    wd_RPort(a0),a0
  4907.         lea    misc_text_1,a1
  4908.         moveq.l    #0,d0
  4909.         moveq.l    #0,d1
  4910.         jsr    PrintIText(a6)
  4911.  
  4912.                 moveq.l #1,d0
  4913.  
  4914. no_key_misc_off:move.l    #misc_jmp_table,function_jmp
  4915.         move.l    #"MISC",function_status
  4916.  
  4917.         lea    misc_win_txt,a1
  4918.         bsr.w    change_win_title
  4919.  
  4920.         bra.w    get_message
  4921.  
  4922. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4923. ;        menu edit prefs
  4924. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4925.  
  4926. menu_edit_prefs:bsr.w    function_window_output
  4927.         tst.l    d0
  4928.         beq.w    get_message
  4929.  
  4930.         cmp.l    #"PREF",function_status
  4931.         beq.w    get_message            ;don't output this twice.
  4932.  
  4933.         bsr.w    gadgets_rmv
  4934.         bsr.w    back_pattern_function
  4935.  
  4936.         move.l    function_ptr,a4
  4937.         lea    prefs_bevel_list,a5
  4938.         bsr.w    draw_bevel_list
  4939.  
  4940.         move.l    context_g_prefs,a1
  4941.         move.l    (a1),a1
  4942.         bsr.w    gadgets_ins
  4943.  
  4944.         tst.l    xpk_master_base
  4945.         bne.s    xpk_master_ok
  4946.  
  4947.         move.l    intuition_base,a6        ;turn off all the xpk gadgets!
  4948.         move.l    prefs_g_battery,a0
  4949.         move.l    function_ptr,a1
  4950.         sub.l    a2,a2
  4951.         jsr    OffGadget(a6)
  4952.  
  4953.         move.l    prefs_g_gbs,a0
  4954.         move.l    function_ptr,a1
  4955.         sub.l    a2,a2
  4956.         jsr    OffGadget(a6)
  4957.  
  4958.         move.l    prefs_g_xpk,a0
  4959.         move.l    function_ptr,a1
  4960.         sub.l    a2,a2
  4961.         jsr    OffGadget(a6)
  4962.  
  4963. xpk_master_ok:    move.l    intuition_base,a6
  4964.         move.l    function_ptr,a0
  4965.         move.l    wd_RPort(a0),a0
  4966.         lea    prefs_text_1,a1
  4967.         moveq.l    #0,d0
  4968.         moveq.l    #0,d1
  4969.         jsr    PrintIText(a6)
  4970.  
  4971.         move.l    #prefs_jmp_table,function_jmp
  4972.         move.l    #"PREF",function_status
  4973.  
  4974.         lea    prefs_win_txt,a1
  4975.         bsr.w    change_win_title
  4976.  
  4977.         bra.w    get_message
  4978.  
  4979. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4980. ;        change the function window title
  4981. ;        INPUT:
  4982. ;        a1    = pointer to the new title.
  4983. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4984.  
  4985. change_win_title:
  4986.         move.l    intuition_base,a6
  4987.         move.l    function_ptr,a0
  4988.         sub.l    a2,a2
  4989.         jsr    SetWindowTitles(a6)
  4990.         rts
  4991.  
  4992.         move.l    prefs_file,a0
  4993.         lea    gameboy_colours,a1
  4994.         moveq.l    #8-1,d0
  4995.  
  4996. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4997. ;        save the configuration file
  4998. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4999.  
  5000. prefs_save_default:
  5001.         move.l    prefs_file,a5
  5002.  
  5003. ;        120*.B    = rom path.
  5004. ;        120*.B    = gbs path.
  5005. ;        120*.B    = prefs path.
  5006. ;        120*.B    = battery path.
  5007. ;        .W    = menu x.
  5008. ;        .W    = menu y.
  5009. ;        .W    = function x.
  5010. ;        .W    = function y.
  5011. ;        .L    = ahi mode id.
  5012. ;        .L    = ahi mixing frequency.
  5013. ;        .B    = sound master.
  5014. ;        .B    = sound quality.
  5015. ;        .B    = sound channel 1.
  5016. ;        .B    = sound channel 2.
  5017. ;        .B    = sound channel 3.
  5018. ;        .B    = sound channel 4.
  5019. ;        .L    = gameboy screen id.
  5020. ;        .B    = render mode.
  5021. ;        .B    = window scaling status.
  5022. ;        .B    = refresh mode.
  5023. ;        .B    = refresh scanline.
  5024. ;        .B    = aga mode.
  5025. ;        .B    = frame update scanline.
  5026. ;        .B    = battery status.
  5027. ;        .B    = battery xpk packing status.
  5028. ;        .B    = xpk packing library.
  5029. ;        .B    = xpk packing status.
  5030. ;        .B    = controller.
  5031. ;        .W    = wzonka x.
  5032. ;        .W    = wzonka y.
  5033. ;        .W    = wzonka dx.
  5034. ;        .W    = wzonka dy.
  5035. ;        8*.L    = colours.
  5036. ;        .B    = sfx y update value.
  5037. ;        .B    = forbid / permit status.
  5038. ;        .B    = os screen speed limit.
  5039. ;        32*20*.B= the 20 recent cartridge names.
  5040. ;        .B    = volume value.
  5041. ;        .B    = colour load status.
  5042.  
  5043.         move.l    prefs_str_1,a2
  5044.         bsr.w    move_req_path
  5045.         move.l    prefs_str_2,a2
  5046.         bsr.w    move_req_path
  5047.         move.l    prefs_str_3,a2
  5048.         bsr.w    move_req_path
  5049.         move.l    prefs_str_4,a2
  5050.         bsr.w    move_req_path
  5051.  
  5052.         move.l    menu_ptr,a0
  5053.         bsr.w    move_win_xy
  5054.         move.l    function_ptr,a0
  5055.         bsr.w    move_win_xy
  5056.  
  5057.         move.l    ahi_mode_id,(a5)+
  5058.         move.l    ahi_mix_freq,(a5)+
  5059.         move.b    snd_master,(a5)+
  5060.         move.b    snd_quality,(a5)+
  5061.         move.b    snd_chnlI,(a5)+
  5062.         move.b    snd_chnlII,(a5)+
  5063.         move.b    snd_chnlIII,(a5)+
  5064.         move.b    snd_chnlIV,(a5)+
  5065.  
  5066.         move.l    gb_screen_id+4,(a5)+
  5067.         move.b    old_render,(a5)+
  5068.         move.b    scaling_status,(a5)+
  5069.         move.b    old_refresh,(a5)+
  5070.         move.b    refresh_scanline,(a5)+
  5071.         move.b    aga_mode,(a5)+
  5072.         move.b    frame_update_number,(a5)+
  5073.  
  5074.         move.b    battery_status,(a5)+
  5075.         move.b    battery_xpk_status,(a5)+
  5076.         move.b    pck_method_number,(a5)+
  5077.         move.b    pck_xpk_status,(a5)+
  5078.         move.b    keystick,(a5)+
  5079.  
  5080.         lea    wzonka_window,a0
  5081.         move.l    wzonka_ptr,d0
  5082.         beq.s    no_wzonka_window_open
  5083.         move.l    d0,a1
  5084.         move.w    wd_LeftEdge(a1),nw_LeftEdge(a0)
  5085.         move.w    wd_TopEdge(a1),nw_TopEdge(a0)
  5086. no_wzonka_window_open:
  5087.         move.w    nw_LeftEdge(a0),(a5)+
  5088.         move.w    nw_TopEdge(a0),(a5)+
  5089.  
  5090.         bsr.w    get_wzonka_window_scaled_dimensions
  5091.         move.w    wzonka_window_x,(a5)+
  5092.         move.w    wzonka_window_y,(a5)+
  5093.  
  5094.         lea    gameboy_colours,a0
  5095.         moveq.l    #8-1,d0
  5096. copy_gameboy_colours:
  5097.         move.l    (a0)+,(a5)+
  5098.         dbra    d0,copy_gameboy_colours        
  5099.  
  5100.         move.b    sfx_y_update,(a5)+
  5101.         move.b    forbid_permit_status,(a5)+
  5102.         move.b    os_screen_speed_limit,(a5)+
  5103.  
  5104.         add.l    #32*20,a5
  5105.  
  5106.         move.b    sfx_volume_value,(a5)+
  5107.         move.b    colour_load_status,(a5)+
  5108.         move.b    fast_ram_bitmaps,(a5)+
  5109.  
  5110. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5111. ;        save the file
  5112. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5113.  
  5114.         move.l    dos_base,a6
  5115.         move.l    #prefs_file_name,d1
  5116.         move.l    #MODE_NEWFILE,d2
  5117.         jsr    Open(a6)
  5118.         move.l    d0,file_hd
  5119.         beq.w    prefs_save_def_x
  5120.  
  5121.         move.l    d0,d1
  5122.         move.l    prefs_file,d2
  5123.         move.l    #2048,d3
  5124.         jsr    Write(a6)
  5125.  
  5126.         move.l    file_hd,d1
  5127.         jsr    Close(a6)
  5128.  
  5129. prefs_save_def_x:
  5130.         bra.w    get_message
  5131.  
  5132. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5133. ;        save window position
  5134. ;        INPUT:
  5135. ;        a0    = window ptr.
  5136. ;        a5    = output.
  5137. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5138.  
  5139. move_win_xy:    move.w    wd_LeftEdge(a0),(a5)
  5140.         move.w    wd_TopEdge(a0),2(a5)
  5141.         addq.l    #4,a5
  5142.         rts
  5143.  
  5144. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5145. ;        save file path
  5146. ;        INPUT:
  5147. ;        a2    = string gadget.
  5148. ;        a5    = output.
  5149. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5150.  
  5151. move_req_path:    moveq.l    #120/4-1,d1
  5152. move_req_path_data:
  5153.         move.l    (a2)+,(a5)+
  5154.         dbra    d1,move_req_path_data
  5155.         rts
  5156.  
  5157. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5158. ;        restore file path and change the requester path
  5159. ;        INPUT:
  5160. ;        d7    = another requester.
  5161. ;        a2    = string gadget.
  5162. ;        a4    = the requester.
  5163. ;        a5    = output.
  5164. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5165.  
  5166. move_req_path_and_change:
  5167.         move.l    a5,a3
  5168.         moveq.l    #120/4-1,d1
  5169. move_req_path_and_change_data:
  5170.         move.l    (a2)+,(a5)+
  5171.         dbra    d1,move_req_path_and_change_data
  5172.         move.l    a2,-(SP)
  5173.  
  5174.         move.l    a4,d0
  5175.         beq.s    move_req_path_and_change_data_no_a4_change_1
  5176.  
  5177.         move.l    req_tools_base,a6
  5178.         lea    req_change_tags,a0
  5179.         move.l    a3,4(a0)            ;new def dir!
  5180.         move.l    a4,a1
  5181.         jsr    rtChangeReqAttrA(a6)        ;change to the default dir.
  5182. move_req_path_and_change_data_no_a4_change_1:
  5183.  
  5184.         tst.l    d7
  5185.         beq.s    move_req_path_and_change_data_no_a4_change_2
  5186.  
  5187.         lea    req_change_tags,a0
  5188.         move.l    a3,4(a0)            ;new def dir!
  5189.         move.l    d7,a1
  5190.         jsr    rtChangeReqAttrA(a6)        ;change to the default dir.
  5191. move_req_path_and_change_data_no_a4_change_2:
  5192.         move.l    (SP)+,a2
  5193.         rts
  5194.  
  5195. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5196. ;        load the configuration file
  5197. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5198.  
  5199. prefs_load_default:
  5200.         move.l    dos_base,a6
  5201.         move.l    #prefs_file_name,d1
  5202.         move.l    #MODE_OLDFILE,d2
  5203.         jsr    Open(a6)
  5204.         move.l    d0,file_hd
  5205.         beq.w    prefs_load_error
  5206.  
  5207.         move.l    d0,d1
  5208.         move.l    prefs_file,d2
  5209.         move.l    #2048,d3
  5210.         jsr    Read(a6)
  5211.  
  5212.         move.l    file_hd,d1
  5213.         jsr    Close(a6)
  5214.  
  5215. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5216. ;        get the values from the prefs file
  5217. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5218.  
  5219.         move.l    prefs_file,a2
  5220.  
  5221.         move.l    request_ptr_get_1,a4
  5222.         move.l    prefs_str_1,a5
  5223.         move.l    request_ptr_lo,d7
  5224.         bsr.w    move_req_path_and_change
  5225.         move.l    request_ptr_get_2,a4
  5226.         move.l    prefs_str_2,a5
  5227.         move.l    request_ptr_ss,d7
  5228.         bsr.w    move_req_path_and_change
  5229.         move.l    request_ptr_get_3,a4
  5230.         move.l    prefs_str_3,a5
  5231.         moveq.l    #0,d7
  5232.         bsr.w    move_req_path_and_change
  5233.         move.l    request_ptr_get_4,a4
  5234.         move.l    prefs_str_4,a5
  5235.         moveq.l    #0,d7
  5236.         bsr.w    move_req_path_and_change
  5237.  
  5238.         lea    menu_window,a0
  5239.         bsr.w    recieve_window_edges
  5240.         lea    function_window,a0
  5241.         bsr.w    recieve_window_edges
  5242.  
  5243.         move.l    (a2)+,ahi_mode_id
  5244.         move.l    (a2)+,ahi_mix_freq
  5245.         move.b    (a2)+,snd_master
  5246.         move.b    (a2)+,snd_quality
  5247.         move.b    (a2)+,snd_chnlI
  5248.         move.b    (a2)+,snd_chnlII
  5249.         move.b    (a2)+,snd_chnlIII
  5250.         move.b    (a2)+,snd_chnlIV
  5251.  
  5252.         move.l    (a2)+,gb_screen_id+4
  5253.  
  5254.         move.l    a2,-(SP)
  5255.         move.l    req_tools_base,a6
  5256.         lea    req_change_screen_mode_tags,a0
  5257.         move.l    gb_screen_id+4,4(a0)
  5258.         move.l    request_ptr_sm,a1
  5259.         jsr    rtChangeReqAttrA(a6)        ;change to the default dir.
  5260.         move.l    (SP)+,a2
  5261.  
  5262.         move.b    (a2)+,old_render
  5263.         move.b    (a2)+,scaling_status
  5264.         move.b    (a2)+,old_refresh
  5265.         move.b    (a2)+,refresh_scanline
  5266.         move.b    (a2)+,aga_mode
  5267.         move.b    (a2)+,frame_update_number
  5268.  
  5269.         move.b    (a2)+,battery_status
  5270.         move.b    (a2)+,battery_xpk_status
  5271.         move.b    (a2)+,pck_method_number
  5272.         move.b    (a2)+,pck_xpk_status
  5273.         move.b    (a2)+,keystick
  5274.  
  5275.         lea    wzonka_window,a0
  5276.         move.w    (a2)+,nw_LeftEdge(a0)
  5277.         move.w    (a2)+,nw_TopEdge(a0)
  5278.         move.w    (a2)+,wzonka_window_x
  5279.         move.w    (a2)+,wzonka_window_y
  5280.  
  5281.         lea    gameboy_colours,a0
  5282.         moveq.l    #8-1,d0
  5283. restore_gameboy_colours:
  5284.         move.l    (a2)+,(a0)+
  5285.         dbra    d0,restore_gameboy_colours        
  5286.  
  5287.         move.b    (a2)+,sfx_y_update
  5288.         move.b    (a2)+,forbid_permit_status
  5289.         move.b    (a2)+,os_screen_speed_limit
  5290.  
  5291.         add.l    #32*20,a2
  5292.  
  5293.         move.b    (a2)+,sfx_volume_value
  5294.         move.b    (a2)+,colour_load_status
  5295.         move.b    (a2)+,fast_ram_bitmaps
  5296.  
  5297.         move.l    xpk_names,a0
  5298.         moveq.l    #0,d0
  5299.         move.b    pck_method_number,d0
  5300.         move.l    (a0,d0.l*4),pck_method        ;xpk library.
  5301.  
  5302.         move.b    frame_update_number,d0
  5303.         addq.b    #1,d0
  5304.         move.b    d0,frame_update
  5305.  
  5306.         bsr.b    get_wzonka_window_flags
  5307.         bsr.b    fix_volume_tables
  5308.  
  5309. prefs_load_error:
  5310.         rts
  5311.  
  5312. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5313. ;        recieve window edges
  5314. ;        INPUT:
  5315. ;        a2    = input.
  5316. ;        a0    = window structure pointer.
  5317. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5318.  
  5319. recieve_window_edges:
  5320.         move.w    (a2)+,nw_LeftEdge(a0)
  5321.         move.w    (a2)+,nw_TopEdge(a0)
  5322.         rts
  5323.  
  5324. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5325. ;        get wzonka game window flags
  5326. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5327.  
  5328. get_wzonka_window_flags:
  5329.         lea    wzonka_window,a0
  5330.         moveq.l    #0,d0
  5331.         move.b    scaling_status,d0
  5332.         move.l    d0,d1
  5333.         mulu.l    #IDCMP_NEWSIZE,d0
  5334.         mulu.l    #WFLG_SIZEGADGET,d1
  5335.         or.l    #wzonka_idcmp,d0
  5336.         move.l    d0,nw_IDCMPFlags(a0)
  5337.         or.l    #wzonka_flags,d1
  5338.         move.l    d1,nw_Flags(a0)
  5339.         rts
  5340.  
  5341. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5342. ;        fix volume tables
  5343. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5344.  
  5345. fix_volume_tables:
  5346.  
  5347.         moveq.l    #17,d0
  5348.         sub.b    sfx_volume_value,d0
  5349.  
  5350.         lea    sound_III_vol+4,a0
  5351.         move.l    #$10000,d1
  5352.         divu.l    d0,d1
  5353.         move.l    d1,d2
  5354.         subq.l    #2,d2
  5355.         move.l    d2,(a0)+
  5356.         lsr.l    #1,d1
  5357.         move.l    d1,d2
  5358.         subq.l    #2,d2
  5359.         move.l    d2,(a0)+
  5360.         lsr.l    #1,d1
  5361.         subq.l    #2,d1
  5362.         move.l    d1,(a0)+            ;sound_III_vol done!
  5363.  
  5364.         lea    sound_env_volumes+4,a0
  5365.         move.l    #$10000/15,d1
  5366.         divu.l    d0,d1
  5367.         moveq.l    #15-1,d2
  5368.         moveq.l    #1,d3
  5369.  
  5370. sound_env_volumes_composer:
  5371.         move.l    d1,d4
  5372.         mulu.l    d3,d4
  5373.         subq.l    #2,d4
  5374.         move.l    d4,(a0)+
  5375.         addq.b    #1,d3
  5376.         dbra    d2,sound_env_volumes_composer
  5377.  
  5378.         rts
  5379.  
  5380. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5381. ;        get the directory (rom)
  5382. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5383.  
  5384. get_prefs_str_1:move.l    prefs_str_1,d7
  5385.         move.l    request_ptr_lo,a4
  5386.         move.l    request_ptr_get_1,a5
  5387.         move.l    prefs_g_str_1,d6
  5388.         bsr.s    get_prefs_str
  5389.  
  5390.         bra.w    get_message
  5391.  
  5392. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5393. ;        get the directory (gbs)
  5394. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5395.  
  5396. get_prefs_str_2:move.l    prefs_str_2,d7
  5397.         move.l    request_ptr_ss,a4
  5398.         move.l    request_ptr_get_2,a5
  5399.         move.l    prefs_g_str_2,d6
  5400.         bsr.s    get_prefs_str
  5401.  
  5402.         bra.w    get_message
  5403.  
  5404. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5405. ;        get the directory (prefs)
  5406. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5407.  
  5408. get_prefs_str_3:move.l    prefs_str_3,d7
  5409.         sub.l    a4,a4
  5410.         move.l    request_ptr_get_3,a5
  5411.         move.l    prefs_g_str_3,d6
  5412.         bsr.s    get_prefs_str
  5413.  
  5414.         bra.w    get_message
  5415.  
  5416. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5417. ;        get the directory (battery)
  5418. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5419.  
  5420. get_prefs_str_4:move.l    prefs_str_4,d7
  5421.         sub.l    a4,a4
  5422.         move.l    request_ptr_get_4,a5
  5423.         move.l    prefs_g_str_4,d6
  5424.         bsr.s    get_prefs_str
  5425.  
  5426.         bra.w    get_message
  5427.  
  5428. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5429. ;        get the directory from the string gadget
  5430. ;        INPUT:
  5431. ;        d6    = the string gadget.
  5432. ;        d7    = the string (output).
  5433. ;        a4    = get requester.
  5434. ;        a5    = changing requester.
  5435. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5436.  
  5437. get_prefs_str:    move.l    gad_tools_base,a6
  5438.         move.l    d6,a0                ;get the gadget.
  5439.         move.l    function_ptr,a1
  5440.         sub.l    a2,a2
  5441.         lea    prefs_g_str_chg,a3
  5442.         move.l    #prefs_str_ptr,4(a3)
  5443.         jsr    GT_GetGadgetAttrsA(a6)        ;get the new text.
  5444.  
  5445.         move.l    d7,a0
  5446.         move.l    prefs_str_ptr,a1
  5447.         moveq.l    #120/4-1,d0
  5448. get_prefs_str_copy_name:
  5449.         move.l    (a1)+,(a0)+
  5450.         dbra    d0,get_prefs_str_copy_name
  5451.  
  5452.         move.l    prefs_str_ptr,a2
  5453.         move.l    def_dir,a0
  5454.         bsr.w    memorize_dir
  5455.  
  5456.         lea    req_change_tags,a0
  5457.         move.l    def_dir,4(a0)            ;new def dir!
  5458.         move.l    req_tools_base,a6
  5459.  
  5460.         move.l    a4,d0
  5461.         beq.s    no_a4_change
  5462.  
  5463.         move.l    a4,a1
  5464.         jsr    rtChangeReqAttrA(a6)        ;change to the default dir.
  5465.  
  5466. no_a4_change:    move.l    a5,a1
  5467.         lea    req_change_tags,a0
  5468.         jsr    rtChangeReqAttrA(a6)        ;change to the default dir.
  5469. get_prefs_str_x:rts
  5470.  
  5471. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5472. ;        get the directory (rom)
  5473. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5474.  
  5475. get_prefs_dir_1:move.l    prefs_str_1,d7
  5476.         move.l    request_ptr_lo,a4
  5477.         move.l    request_ptr_get_1,a5
  5478.         move.l    prefs_g_str_1,d6
  5479.         bsr.s    get_prefs_dir
  5480.  
  5481.         bra.w    get_message
  5482.  
  5483. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5484. ;        get the directory (gbs)
  5485. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5486.  
  5487. get_prefs_dir_2:move.l    prefs_str_2,d7
  5488.         move.l    request_ptr_ss,a4
  5489.         move.l    request_ptr_get_2,a5
  5490.         move.l    prefs_g_str_2,d6
  5491.         bsr.s    get_prefs_dir
  5492.  
  5493.         bra.w    get_message
  5494.  
  5495. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5496. ;        get the directory (prefs)
  5497. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5498.  
  5499. get_prefs_dir_3:move.l    prefs_str_3,d7
  5500.         sub.l    a4,a4
  5501.         move.l    request_ptr_get_3,a5
  5502.         move.l    prefs_g_str_3,d6
  5503.         bsr.s    get_prefs_dir
  5504.  
  5505.         bra.w    get_message
  5506.  
  5507. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5508. ;        get the directory (battery)
  5509. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5510.  
  5511. get_prefs_dir_4:move.l    prefs_str_4,d7
  5512.         sub.l    a4,a4
  5513.         move.l    request_ptr_get_4,a5
  5514.         move.l    prefs_g_str_4,d6
  5515.         bsr.s    get_prefs_dir
  5516.  
  5517.         bra.w    get_message
  5518.  
  5519. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5520. ;        get the directory
  5521. ;        INPUT:
  5522. ;        d6    = the string gadget.
  5523. ;        d7    = the string (output).
  5524. ;        a4    = get requester.
  5525. ;        a5    = changing requester.
  5526. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5527.  
  5528. get_prefs_dir:    move.l    req_tools_base,a6
  5529.         lea    req_get_dir_tag,a0        ;the tags.
  5530.         move.l    menu_ptr,4(a0)            ;the position pointer.
  5531.         move.l    a5,a1                ;the requester pointer.
  5532.         move.l    name_ptr,a2            ;the output area.
  5533.         lea    request_get_dir,a3        ;the title text.
  5534.         jsr    rtFileRequestA(a6)        ;open a file requester.
  5535.  
  5536.         move.l    d7,a0
  5537.         move.l    rtfi_Dir(a5),a1
  5538.         moveq.l    #120/4-1,d0
  5539. get_prefs_dir_copy_name:
  5540.         move.l    (a1)+,(a0)+
  5541.         dbra    d0,get_prefs_dir_copy_name
  5542.  
  5543.         move.l    rtfi_Dir(a5),a2
  5544.         move.l    def_dir,a0
  5545.         bsr.w    memorize_dir            ;memorize the dir.
  5546.  
  5547.         tst.l    d0                ;from the requester.
  5548.         beq.w    get_prefs_dir_e            ;error! none selected!
  5549.  
  5550.         move.l    a4,d0
  5551.         beq.s    no_change_a4
  5552.  
  5553.         move.l    a4,a1
  5554.         lea    req_change_tags,a0
  5555.         move.l    def_dir,4(a0)            ;new def dir!
  5556.         jsr    rtChangeReqAttrA(a6)        ;change to the default dir.
  5557.  
  5558. no_change_a4:    move.l    gad_tools_base,a6
  5559.         move.l    d6,a0                ;get the gadget.
  5560.         move.l    function_ptr,a1
  5561.         sub.l    a2,a2
  5562.         lea    prefs_g_str_chg,a3
  5563.         move.l    def_dir,4(a3)
  5564.         jsr    GT_SetGadgetAttrsA(a6)        ;set the new text.
  5565. get_prefs_dir_e:rts
  5566.  
  5567. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5568. ;        save the twenty recently loaded cartridge names
  5569. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5570.  
  5571. save_20_recent:    move.l    dos_base,d0
  5572.         beq.s    exit_20
  5573.         tst.l    prefs_file
  5574.         beq.s    exit_20
  5575.  
  5576.         move.l    d0,a6
  5577.         move.l    #prefs_file_name,d1
  5578.         move.l    #MODE_OLDFILE,d2
  5579.         jsr    Open(a6)
  5580.         move.l    d0,d7
  5581.         beq.w    exit_20
  5582.  
  5583.         move.l    d0,d1
  5584.         move.l    #560,d2                ;to name fields.
  5585.         move.l    #OFFSET_BEGINNING,d3        ;offset.
  5586.         jsr    Seek(a6)
  5587.  
  5588.         move.l    d7,d1
  5589.         move.l    prefs_file,d2
  5590.         add.l    #560,d2                ;to name fields.
  5591.         move.l    #32*20,d3
  5592.         jsr    Write(a6)
  5593.  
  5594.         move.l    d7,d1
  5595.         jsr    Close(a6)
  5596. exit_20:    rts
  5597.  
  5598. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5599. ;        delete five temporary gbs files
  5600. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5601.  
  5602. delete_five_gbs:
  5603.  
  5604.         move.l    dos_base,d0
  5605.         beq.s    delete_five_gbs_exit
  5606.         move.l    d0,a6
  5607.  
  5608.         moveq.l    #5-1,d7
  5609.         move.b    #"5",d6
  5610.  
  5611.         move.l    dir_n_name_ptr,d0
  5612.         beq.s    delete_five_gbs_exit
  5613.         move.l    d0,a0                ;the name of the file.
  5614.         move.l    #"T:Wz",(a0)+
  5615.         move.l    #"onka",(a0)+
  5616.         move.l    #"-Lad",(a0)+
  5617.         move.l    #".RT.",(a0)+
  5618.         move.w    #"GB",(a0)+
  5619.         move.b    #"S",(a0)+
  5620.         move.l    a0,a5
  5621.         move.b    d6,(a0)+
  5622.         clr.b    (a0)
  5623.  
  5624. delete_five_gbs_all:
  5625.         move.l    dir_n_name_ptr,d1
  5626.         jsr    DeleteFile(a6)
  5627.  
  5628.         subq.b    #1,d6
  5629.         move.b    d6,(a5)
  5630.         dbra    d7,delete_five_gbs_all
  5631.  
  5632. delete_five_gbs_exit:
  5633.         rts
  5634.  
  5635. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5636. ;        quit / exit
  5637. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5638.  
  5639. quit:
  5640.         IFGT    GAMEBOY_SERIAL
  5641.  
  5642.         bsr.w    serial_deallocate
  5643.  
  5644.         ENDIF
  5645.  
  5646.         bsr.w    save_20_recent
  5647.         bsr.w    save_battery_ram
  5648.         bsr.w    delete_five_gbs
  5649.  
  5650.         IFGT    GAMEBOY_DEBUG
  5651.  
  5652.         move.l    dos_base,a6
  5653.         move.l    debug_con_handle,d1
  5654.         jsr    Close(a6)
  5655.  
  5656.         ENDIF
  5657.  
  5658.         lea    cartridge_data,a5
  5659.         bsr.w    free_vec
  5660.         lea    rom_32k,a5
  5661.         bsr.w    free_vec
  5662.         lea    xpk_names_list,a5
  5663.         bsr.w    free_vec
  5664.         lea    xpk_names_all,a5
  5665.         bsr.w    free_vec
  5666.         lea    gg_list,a5
  5667.         bsr.w    free_vec
  5668.  
  5669.         move.l    pub_screen_lock,d0
  5670.         beq.s    no_pens_for_freeing
  5671.         lea    pen_list,a4
  5672.         move.l    d0,a5
  5673.         lea    sc_ViewPort(a5),a5
  5674.         move.l    vp_ColorMap(a5),a5
  5675.         move.l    graphics_base,a6
  5676.         moveq.l    #8-1,d7
  5677. free_pens:    moveq.l    #0,d0
  5678.         move.b    (a4)+,d0
  5679.         move.l    a5,a0
  5680.         jsr    ReleasePen(a6)
  5681.         dbra    d7,free_pens
  5682.  
  5683. no_pens_for_freeing:
  5684.         move.l    pub_screen_lock,d0
  5685.         beq.s    no_pub_lock
  5686.         move.l    d0,a1
  5687.         sub.l    a0,a0                ;no name.
  5688.         move.l    intuition_base,a6
  5689.         jsr    UnlockPubScreen(a6)
  5690.  
  5691. no_pub_lock:    move.l    request_ptr_lo,d0
  5692.         bsr.w    free_reqs
  5693.         move.l    request_ptr_ss,d0
  5694.         bsr.w    free_reqs
  5695.         move.l    request_ptr_sm,d0
  5696.         bsr.w    free_reqs
  5697.         move.l    request_ptr_get_1,d0
  5698.         bsr.w    free_reqs
  5699.         move.l    request_ptr_get_2,d0
  5700.         bsr.w    free_reqs
  5701.         move.l    request_ptr_get_3,d0
  5702.         bsr.w    free_reqs
  5703.         move.l    request_ptr_get_4,d0
  5704.         bsr.w    free_reqs
  5705.  
  5706.         move.l    font_ptr,d0
  5707.         beq.s    no_font                ;no font opened.
  5708.         move.l    d0,a1
  5709.         move.l    graphics_base,a6
  5710.         jsr    CloseFont(a6)            ;close the font.
  5711.  
  5712. no_font:    bsr.w    gadgets_rmv
  5713.  
  5714.         move.l    menu_ptr,d0
  5715.         beq.s    no_menu
  5716.         move.l    d0,a0
  5717.         move.l    intuition_base,a6
  5718.         jsr    ClearMenuStrip(a6)        ;clear menus.
  5719.  
  5720. no_menu:    lea    menu_ptr,a5
  5721.         bsr.w    close_window
  5722.         lea    function_ptr,a5
  5723.         bsr.w    close_window
  5724.         lea    wzonka_ptr,a5
  5725.         bsr.w    close_window
  5726.  
  5727.         bsr.w    dbuf_dealloc            ;free dbuf.
  5728.         bsr.w    free_gg_linked_list        ;free game genie code list.
  5729.  
  5730.         move.l    context_g_menu,a5
  5731.         bsr.w    free_gadgets
  5732.         move.l    context_g_sfx,a5
  5733.         bsr.w    free_gadgets
  5734.         move.l    context_g_prefs,a5
  5735.         bsr.w    free_gadgets
  5736.         move.l    context_g_gfx,a5
  5737.         bsr.w    free_gadgets
  5738.         move.l    context_g_misc,a5
  5739.         bsr.w    free_gadgets
  5740.  
  5741.         move.l    visual_info,d0
  5742.         beq.s    no_visual_info
  5743.         move.l    d0,a0
  5744.         move.l    gad_tools_base,a6
  5745.         jsr    FreeVisualInfo(a6)
  5746.  
  5747. no_visual_info:    move.l    message_port,d0
  5748.         beq.s    no_message_port
  5749.         move.l    d0,a1
  5750.         move.l    exec_base,a6
  5751.         jsr    RemPort(a6)
  5752.  
  5753.         move.l    message_port,a0
  5754.         jsr    DeleteMsgPort(a6)
  5755.  
  5756. no_message_port:lea    gfx_game_still_tmp_map_attr,a1
  5757.         bsr.w    free_bit_maps
  5758.  
  5759.         lea    list_default,a5
  5760.         bsr.w    free_vectors            ;free the allocated memory.
  5761.  
  5762.         bsr.w    close_graphics
  5763.         bsr.w    close_ahi
  5764.  
  5765.         move.l    cyber_base,d0
  5766.         bsr.b    free_libs
  5767.         move.l    xpk_master_base,d0
  5768.         bsr.b    free_libs
  5769.         move.l    low_level_base,d0
  5770.         bsr.b    free_libs
  5771.         move.l    control_pad_base,d0
  5772.         bsr.b    free_libs
  5773.         move.l    req_tools_base,d0
  5774.         bsr.b    free_libs
  5775.         move.l    gad_tools_base,d0
  5776.         bsr.b    free_libs
  5777.         move.l    graphics_base,d0
  5778.         bsr.b    free_libs
  5779.         move.l    dos_base,d0
  5780.         bsr.b    free_libs
  5781.         move.l    disk_font_base,d0
  5782.         bsr.b    free_libs
  5783.  
  5784.         movem.l    (SP)+,d2-d7/a2-a6        ;unstack!
  5785.         moveq.l    #0,d0                ;no errors.
  5786.         rts
  5787.  
  5788. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5789. ;        misc closes
  5790. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5791.  
  5792. free_vec:    tst.l    (a5)
  5793.         beq.s    free_vec_x
  5794.         move.l    (a5),a1
  5795.         move.l    exec_base,a6
  5796.         jsr    FreeVec(a6)            ;free the area.
  5797.         clr.l    (a5)
  5798. free_vec_x:    rts
  5799.  
  5800. free_reqs:    move.l    d0,a1
  5801.         beq.s    free_reqs_x
  5802.         move.l    req_tools_base,a6
  5803.         jsr    rtFreeRequest(a6)        ;free the requester
  5804. free_reqs_x:    rts
  5805.  
  5806. free_libs:    move.l    d0,a1
  5807.         beq.s    free_libs_x
  5808.         move.l    exec_base,a6
  5809.         jsr    CloseLibrary(a6)
  5810. free_libs_x:    rts
  5811.  
  5812. close_window:    tst.l    (a5)
  5813.         beq.s    close_window_x
  5814.         move.l    (a5),a0
  5815.         move.l    intuition_base,a6
  5816.         jsr    CloseWindow(a6)
  5817.         clr.l    (a5)
  5818. close_window_x:    rts
  5819.  
  5820. free_gadgets:    tst.l    (a5)
  5821.         beq.s    free_gadgets_x
  5822.         move.l    (a5),a0
  5823.         clr.l    (a5)
  5824.         move.l    gad_tools_base,a6
  5825.         jsr    FreeGadgets(a6)        
  5826. free_gadgets_x:    rts
  5827.  
  5828. free_bit_maps:    tst.l    (a1)
  5829.         beq.s    no_bit_map
  5830.         move.l    (a1),a0
  5831.         clr.l    (a1)
  5832.         move.l    graphics_base,a6
  5833.         jsr    FreeBitMap(a6)
  5834. no_bit_map:    rts
  5835.  
  5836. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5837. ;        copy rast port
  5838. ;        INPUT:
  5839. ;        a0    = source.
  5840. ;        a1    = target.
  5841. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5842.  
  5843. copy_rast_port:    move.w    #rp_SIZEOF-1,d0
  5844. copy_rast_port_data:
  5845.         move.b    (a0)+,(a1)+
  5846.         dbra    d0,copy_rast_port_data
  5847.         rts
  5848.  
  5849. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5850. ;        serial allocate
  5851. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5852.  
  5853.         IFGT    GAMEBOY_SERIAL
  5854.  
  5855. serial_allocate:move.l    exec_base,a6
  5856.         jsr    CreateMsgPort(a6)
  5857.         move.l    d0,input_message_port
  5858.         beq.w    serial_allocate_error
  5859.  
  5860.         jsr    CreateMsgPort(a6)
  5861.         move.l    d0,output_message_port
  5862.         beq.w    serial_allocate_error
  5863.  
  5864.         move.l    input_message_port,a0
  5865.         move.l    #IOEXTSER_SIZE,d0
  5866.         jsr    CreateIORequest(a6)
  5867.         move.l    d0,io_request_in
  5868.         beq.w    serial_allocate_error
  5869.  
  5870.         move.l    output_message_port,a0
  5871.         move.l    #IOEXTSER_SIZE,d0
  5872.         jsr    CreateIORequest(a6)
  5873.         move.l    d0,io_request_out
  5874.         beq.s    serial_allocate_error
  5875.  
  5876.         lea    serial_device_name,a0
  5877.         move.l    io_request_in,a1
  5878.  
  5879.         bset.b    #5,IO_SERFLAGS(a1)        ;shared access!
  5880.         moveq.l    #0,d0
  5881.         moveq.l    #0,d1
  5882.         jsr    OpenDevice(a6)
  5883.         tst.l    d0
  5884.         bne.s    serial_allocate_error
  5885.  
  5886.         lea    serial_device_name,a0
  5887.         move.l    io_request_out,a1
  5888.         bset.b    #5,IO_SERFLAGS(a1)        ;shared access!
  5889.         moveq.l    #0,d0
  5890.         moveq.l    #0,d1
  5891.         jsr    OpenDevice(a6)
  5892.         tst.l    d0
  5893.         bne.s    serial_allocate_error
  5894.  
  5895.         move.b    #1,serial_device_status
  5896.  
  5897.         move.l    io_request_in,a1
  5898.         move.l    #1,IO_LENGTH(a1)
  5899.         move.l    io_buffer_in,IO_DATA(a1)
  5900.         move.w    #SDCMD_QUERY,IO_COMMAND(a1)
  5901.         jsr    DoIO(a6)
  5902.         tst.l    d0
  5903.         bne.s    serial_allocate_error
  5904.  
  5905. ;        move.l    io_request_in,a0
  5906. ;        move.w    IO_STATUS(a0),d0
  5907. ;        btst    #5,d0
  5908. ;        bne.s    serial_allocate_error
  5909.  
  5910.         moveq.l    #0,d0
  5911.         rts
  5912.  
  5913. ;serial_allocate_error:
  5914.         moveq.l    #1,d0
  5915.         rts
  5916.  
  5917.         ENDIF
  5918.  
  5919. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5920. ;        serial deallocate
  5921. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5922.  
  5923.         IFGT    GAMEBOY_SERIAL
  5924.  
  5925. serial_deallocate:
  5926.         move.l    exec_base,a6
  5927.         move.l    io_request_in,d0
  5928.         beq.s    no_io_request_in
  5929.         move.l    d0,a1
  5930.         jsr    AbortIO(a6)
  5931.  
  5932. no_io_request_in:
  5933.         move.l    io_request_out,d0
  5934.         beq.s    no_io_request_out
  5935.         move.l    d0,a1
  5936.         jsr    AbortIO(a6)
  5937.  
  5938.         tst.b    serial_device_status
  5939.         beq.s    no_close_device
  5940.         move.l    io_request_in,a1
  5941.         jsr    CloseDevice(a6)
  5942.         move.l    io_request_out,a1
  5943.         jsr    CloseDevice(a6)
  5944.  
  5945. no_close_device:move.l    io_request_in,a0
  5946.         jsr    DeleteIORequest(a6)
  5947.         move.l    io_request_out,a0
  5948.         jsr    DeleteIORequest(a6)
  5949.  
  5950. no_io_request_out:
  5951.         move.l    input_message_port,d0
  5952.         beq.s    no_input_message_port
  5953.         move.l    d0,a0
  5954.         jsr    DeleteMsgPort(a6)
  5955.  
  5956. no_input_message_port:
  5957.         move.l    output_message_port,d0
  5958.         beq.s    no_output_message_port
  5959.         move.l    d0,a0
  5960.         jsr    DeleteMsgPort(a6)
  5961.  
  5962. no_output_message_port:
  5963.         rts
  5964.  
  5965.         ENDIF
  5966.  
  5967. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5968. ;        save rom prefs
  5969. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5970.  
  5971. save_prefs:    tst.l    cartridge
  5972.         beq.w    save_prefs_exit
  5973.  
  5974.         move.l    prefs_str_3,prefs_str_ptr
  5975.         bsr.w    get_cartridge_path_and_name
  5976.         move.l    #".pre",(a0)+            ;the ending.
  5977.         move.w    #"fs",(a0)+
  5978.         clr.b    (a0)
  5979.  
  5980.         move.l    prefs_file_rom,a5
  5981.         lea    gameboy_colours,a1
  5982.         moveq.l    #8-1,d0
  5983. save_colours_apply:
  5984.         move.b    1(a1),(a5)+
  5985.         move.b    2(a1),(a5)+
  5986.         move.b    3(a1),(a5)+
  5987.         addq.l    #4,a1
  5988.         dbra    d0,save_colours_apply
  5989.  
  5990.         move.b    refresh_scanline,(a5)+
  5991.         move.b    frame_update_number,(a5)+
  5992.  
  5993.         sub.l    prefs_file_rom,a5
  5994.  
  5995.         move.l    dos_base,a6            ;open the data file.
  5996.         move.l    dir_n_name_ptr,d1        ;the name of the file.
  5997.         move.l    #MODE_NEWFILE,d2
  5998.         jsr    Open(a6)
  5999.         move.l    d0,d7
  6000.         beq.w    save_prefs_exit
  6001.  
  6002.         move.l    d0,d1
  6003.         move.l    prefs_file_rom,d2
  6004.         move.l    a5,d3
  6005.         jsr    Write(a6)
  6006.  
  6007.         move.l    d7,d1
  6008.         jsr    Close(a6)
  6009.  
  6010. save_prefs_exit:bra.w    get_message
  6011.  
  6012. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6013. ;        load the preferences for a cartridge
  6014. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6015.  
  6016. ;        3*4*2.B    = colours.
  6017. ;        .B    = refresh scanline.
  6018. ;        .B    = frameskip.
  6019.  
  6020. load_prefs:    move.l    prefs_str_3,prefs_str_ptr
  6021.         bsr.w    get_cartridge_path_and_name
  6022.         move.l    #".pre",(a0)+            ;the ending.
  6023.         move.w    #"fs",(a0)+
  6024.         clr.b    (a0)
  6025.  
  6026.         move.l    dos_base,a6
  6027.         move.l    dir_n_name_ptr,d1
  6028.         moveq.l    #ACCESS_READ,d2
  6029.         jsr    Lock(a6)
  6030.         move.l    d0,file_hd
  6031.         beq.w    load_prefs_error
  6032.  
  6033.         move.l    file_info_ptr,d2
  6034.         move.l    d0,d1
  6035.         jsr    Examine(a6)
  6036.  
  6037.         move.l    file_hd,d1
  6038.         jsr    UnLock(a6)
  6039.  
  6040.         move.l    file_info_ptr,a0
  6041.         move.l    fib_Size(a0),d7
  6042.  
  6043.         move.l    dos_base,a6
  6044.         move.l    dir_n_name_ptr,d1
  6045.         move.l    #MODE_OLDFILE,d2
  6046.         jsr    Open(a6)
  6047.         move.l    d0,file_hd
  6048.         beq.w    load_prefs_error
  6049.  
  6050.         move.l    d0,d1
  6051.         move.l    prefs_file_rom,d2
  6052.         move.l    d7,d3
  6053.         jsr    Read(a6)
  6054.  
  6055.         move.l    file_hd,d1
  6056.         jsr    Close(a6)
  6057.  
  6058.         move.l    prefs_file_rom,a0
  6059.         add.l    #3*8,a0                ;skip the colours.
  6060.  
  6061.         cmp.b    #30,d7
  6062.         beq.w    load_prefs_old_prefs_file
  6063.         cmp.b    #27,d7
  6064.         beq.s    load_prefs_new_prefs_file
  6065.         cmp.b    #26,d7
  6066.         beq.s    load_prefs_099_13_prefs_file
  6067.         cmp.b    #25,d7
  6068.         beq.s    load_prefs_097_prefs_file
  6069.         rts                    ;not a real prefs file.
  6070.  
  6071. load_prefs_099_13_prefs_file:
  6072.         move.b    (a0),refresh_scanline
  6073.         move.b    1(a0),d0
  6074.         move.b    d0,frame_update_number
  6075.         addq.b    #1,d0
  6076.         move.b    d0,frame_update
  6077.         bra.s    load_prefs_colours
  6078.  
  6079. load_prefs_097_prefs_file:
  6080.         move.b    (a0),refresh_scanline
  6081.         bra.s    load_prefs_colours
  6082.  
  6083. load_prefs_new_prefs_file:
  6084.         move.b    (a0),refresh_scanline
  6085.         bra.s    load_prefs_colours
  6086.  
  6087. load_prefs_old_prefs_file:
  6088.         addq.l    #4,a0                ;skip frame skip and render.
  6089.         move.w    (a0),d0
  6090.         mulu.w    #3-1,d0
  6091.         divu.l    #MAXPOT,d0
  6092.         tst.b    d0
  6093.         beq.s    load_prefs_old_prefs_file_obsolete_1
  6094.         cmp.b    #1,d0
  6095.         beq.s    load_prefs_old_prefs_file_obsolete_2
  6096.         cmp.b    #2,d0
  6097.         beq.s    load_prefs_old_prefs_file_obsolete_3
  6098.         bra.s    load_prefs_colours
  6099.  
  6100. load_prefs_old_prefs_file_obsolete_1:
  6101.         bra.s    load_prefs_colours
  6102.  
  6103. load_prefs_old_prefs_file_obsolete_2:
  6104.         move.b    #144,refresh_scanline
  6105.         bra.s    load_prefs_colours
  6106.  
  6107. load_prefs_old_prefs_file_obsolete_3:
  6108.         move.b    #153,refresh_scanline
  6109.  
  6110. load_prefs_colours:
  6111.         tst.b    colour_load_status
  6112.         beq.s    load_prefs_colours_exit
  6113.  
  6114.         move.l    prefs_file_rom,a0
  6115.         lea    gameboy_colours,a1
  6116.         moveq.l    #8-1,d0
  6117.  
  6118. load_prefs_colours_apply:
  6119.         addq.l    #1,a1
  6120.         move.b    (a0)+,(a1)+
  6121.         move.b    (a0)+,(a1)+
  6122.         move.b    (a0)+,(a1)+
  6123.         dbra    d0,load_prefs_colours_apply
  6124.  
  6125. load_prefs_colours_exit:
  6126.         move.b    #1,gfx_values_need_update
  6127.         bsr.b    gfx_values_update
  6128.  
  6129. load_prefs_error:
  6130.         rts
  6131.  
  6132. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6133. ;        update gfx gadgets and colours
  6134. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6135.  
  6136. gfx_values_update:
  6137.         tst.b    gfx_values_need_update
  6138.         beq.s    gfx_values_update_exit        ;no need to update.
  6139.  
  6140.         tst.l    function_ptr
  6141.         beq.s    gfx_values_update_exit        ;no window to update.
  6142.  
  6143.         cmp.l    #"GFX!",function_status
  6144.         bne.s    gfx_values_update_exit
  6145.  
  6146.         bsr.w    obtain_colours_apply        ;use the colours.
  6147.  
  6148.         move.l    gfx_g_scanline_x,a0
  6149.         lea    alter_tags_slider,a3
  6150.         move.b    refresh_scanline,d0
  6151.         bsr.w    set_gadget_attributes
  6152.  
  6153.         move.l    gfx_g_frame_skip,a0
  6154.         lea    alter_tags_slider,a3
  6155.         move.b    frame_update_number,d0
  6156.         bsr.w    set_gadget_attributes
  6157.  
  6158.         clr.b    gfx_values_need_update        ;updated.
  6159.  
  6160. gfx_values_update_exit:
  6161.         rts
  6162.  
  6163. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6164. ;        load game_genie/game_genie.list
  6165. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6166.  
  6167. load_game_genie_list:
  6168.         move.l    dos_base,a6
  6169.         move.l    #gg_list_name,d1
  6170.         moveq.l    #ACCESS_READ,d2
  6171.         jsr    Lock(a6)
  6172.         move.l    d0,d7
  6173.         beq.s    load_game_genie_list_error
  6174.  
  6175.         move.l    file_info_ptr,d2
  6176.         move.l    d0,d1
  6177.         jsr    Examine(a6)
  6178.  
  6179.         move.l    d7,d1
  6180.         jsr    UnLock(a6)
  6181.  
  6182.         move.l    file_info_ptr,a0
  6183.         move.l    fib_Size(a0),gg_list_size
  6184.  
  6185.         move.l    #gg_list_name,d1
  6186.         move.l    #MODE_OLDFILE,d2
  6187.         jsr    Open(a6)
  6188.         move.l    d0,d7
  6189.         beq.s    load_game_genie_list_error
  6190.  
  6191.         move.l    exec_base,a6
  6192.         move.l    gg_list_size,d0
  6193.         moveq.l    #MEMF_PUBLIC,d1
  6194.         jsr    AllocVec(a6)
  6195.         move.l    d0,gg_list
  6196.         beq.s    load_game_genie_list_error_close
  6197.  
  6198.         move.l    dos_base,a6
  6199.         move.l    d7,d1
  6200.         move.l    d0,d2
  6201.         move.l    gg_list_size,d3
  6202.         jsr    Read(a6)
  6203.  
  6204. load_game_genie_list_error_close:
  6205.         move.l    dos_base,a6
  6206.         move.l    d7,d1
  6207.         jsr    Close(a6)
  6208.  
  6209. load_game_genie_list_error:
  6210.         rts
  6211.  
  6212. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6213. ;        set gadget attributes
  6214. ;        INPUT:
  6215. ;        d0    = new value (.B).
  6216. ;        a0    = gadget.
  6217. ;        a3    = taglist.
  6218. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6219.  
  6220. set_gadget_attributes:
  6221.         and.l    #$ff,d0
  6222.         move.l    d0,4(a3)
  6223.         move.l    gad_tools_base,a6
  6224.         move.l    function_ptr,a1
  6225.         sub.l    a2,a2
  6226.         jsr    GT_SetGadgetAttrsA(a6)
  6227.         rts
  6228.  
  6229. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6230. ;        try to load and parse the twenty favourite rom images list
  6231. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6232.  
  6233. do_menu_items:    move.l    prefs_file,a0
  6234.         add.l    #560,a0                ;to name fields.
  6235.         move.l    a0,men_I_txt
  6236.         add.l    #32,a0
  6237.         move.l    a0,men_II_txt
  6238.         add.l    #32,a0
  6239.         move.l    a0,men_III_txt
  6240.         add.l    #32,a0
  6241.         move.l    a0,men_IV_txt
  6242.         add.l    #32,a0
  6243.         move.l    a0,men_V_txt
  6244.         add.l    #32,a0
  6245.         move.l    a0,men_VI_txt
  6246.         add.l    #32,a0
  6247.         move.l    a0,men_VII_txt
  6248.         add.l    #32,a0
  6249.         move.l    a0,men_VIII_txt
  6250.         add.l    #32,a0
  6251.         move.l    a0,men_IX_txt
  6252.         add.l    #32,a0
  6253.         move.l    a0,men_X_txt
  6254.         add.l    #32,a0
  6255.         move.l    a0,men_1I_txt
  6256.         add.l    #32,a0
  6257.         move.l    a0,men_1II_txt
  6258.         add.l    #32,a0
  6259.         move.l    a0,men_1III_txt
  6260.         add.l    #32,a0
  6261.         move.l    a0,men_1IV_txt
  6262.         add.l    #32,a0
  6263.         move.l    a0,men_1V_txt
  6264.         add.l    #32,a0
  6265.         move.l    a0,men_1VI_txt
  6266.         add.l    #32,a0
  6267.         move.l    a0,men_1VII_txt
  6268.         add.l    #32,a0
  6269.         move.l    a0,men_1VIII_txt
  6270.         add.l    #32,a0
  6271.         move.l    a0,men_1IX_txt
  6272.         add.l    #32,a0
  6273.         move.l    a0,men_1X_txt
  6274.  
  6275.         move.l    dos_base,a6
  6276.         move.l    #menu_favo_nm,d1
  6277.         moveq.l    #ACCESS_READ,d2
  6278.         jsr    Lock(a6)
  6279.         move.l    d0,file_hd
  6280.         beq.w    menu_favo_erro
  6281.  
  6282.         move.l    file_info_ptr,d2
  6283.         move.l    file_hd,d1
  6284.         jsr    Examine(a6)
  6285.  
  6286.         move.l    file_hd,d1
  6287.         jsr    UnLock(a6)
  6288.  
  6289.         move.l    file_info_ptr,a0
  6290.         move.l    124(a0),file_length        ;store the length.
  6291.  
  6292.         move.l    exec_base,a6
  6293.         move.l    file_length,d0
  6294.         moveq.l    #MEMF_PUBLIC,d1
  6295.         jsr    AllocVec(a6)
  6296.         move.l    d0,menu_favo_fl
  6297.         beq.w    menu_favo_erro
  6298.  
  6299.         move.l    dos_base,a6
  6300.         move.l    #menu_favo_nm,d1
  6301.         move.l    #MODE_OLDFILE,d2
  6302.         jsr    Open(a6)
  6303.         move.l    d0,file_hd
  6304.         beq.w    menu_favo_erro
  6305.  
  6306.         move.l    d0,d1
  6307.         move.l    menu_favo_fl,d2
  6308.         move.l    file_length,d3
  6309.         jsr    Read(a6)
  6310.  
  6311.         move.l    file_hd,d1
  6312.         jsr    Close(a6)
  6313.  
  6314. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6315. ;        now search and do the names
  6316. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6317.  
  6318.         move.l    #menu_favourite,menu_recent    ;add one menu more.
  6319.  
  6320.         moveq.l    #20-1,d0            ;max names.
  6321.         move.l    menu_favo_nf,a0            ;output.
  6322.         move.b    #"a",d1                ;first letter.
  6323. menu_favo_find:    move.l    menu_favo_fl,a1            ;input.
  6324.         move.l    file_length,d2            ;size.
  6325.         move.b    d1,d3
  6326.         lsl.w    #8,d3
  6327.         move.b    #".",d3                ;d3 = id word.
  6328. menu_favo_go:    cmp.w    (a1),d3
  6329.         beq.s    menu_favo_ef            ;entry found!
  6330.  
  6331. menu_favo_nlin:    move.b    (a1),d4
  6332.         cmp.b    #$a,d4                ;next line?
  6333.         bne.s    menu_favo_nnli            ;nope.
  6334.         addq.l    #1,a1
  6335.         subq.l    #1,d2
  6336.         beq.s    menu_favo_nent            ;end of file!
  6337.         bra.s    menu_favo_go            ;new line, try again!
  6338.  
  6339. menu_favo_nnli:    addq.l    #1,a1
  6340.         subq.l    #1,d2
  6341.         bne.s    menu_favo_nlin            ;loop through the data.
  6342.  
  6343. menu_favo_nent:    addq.b    #1,d1                ;next letter.
  6344.         add.l    #32,a0                ;next output entry.
  6345.         dbra    d0,menu_favo_find        ;search for it.
  6346.         bra.s    menu_favo_ptrs            ;all names are done.
  6347.  
  6348. menu_favo_ef:    addq.l    #3,a1                ;skip the header plus one
  6349.         moveq.l    #32-1,d4            ;space.
  6350.         move.l    a0,a2
  6351. menu_favo_ec:    move.b    (a1)+,d5
  6352.         cmp.b    #$a,d5
  6353.         beq.s    menu_favo_nent            ;next entry.
  6354.         cmp.b    #0,d5
  6355.         beq.s    menu_favo_nent            ;next entry.
  6356.         move.b    d5,(a2)+
  6357.         dbra    d4,menu_favo_ec            ;next letter.
  6358.         bra.s    menu_favo_nent            ;next entry.
  6359.  
  6360. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6361. ;        copy the name pointers
  6362. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6363.  
  6364. menu_favo_ptrs:    move.l    menu_favo_nf,a0            ;the names.
  6365.         move.l    a0,men_f_I_txt
  6366.         add.l    #32,a0
  6367.         move.l    a0,men_f_II_txt
  6368.         add.l    #32,a0
  6369.         move.l    a0,men_f_III_txt
  6370.         add.l    #32,a0
  6371.         move.l    a0,men_f_IV_txt
  6372.         add.l    #32,a0
  6373.         move.l    a0,men_f_V_txt
  6374.         add.l    #32,a0
  6375.         move.l    a0,men_f_VI_txt
  6376.         add.l    #32,a0
  6377.         move.l    a0,men_f_VII_txt
  6378.         add.l    #32,a0
  6379.         move.l    a0,men_f_VIII_txt
  6380.         add.l    #32,a0
  6381.         move.l    a0,men_f_IX_txt
  6382.         add.l    #32,a0
  6383.         move.l    a0,men_f_X_txt
  6384.         add.l    #32,a0
  6385.         move.l    a0,men_f_1I_txt
  6386.         add.l    #32,a0
  6387.         move.l    a0,men_f_1II_txt
  6388.         add.l    #32,a0
  6389.         move.l    a0,men_f_1III_txt
  6390.         add.l    #32,a0
  6391.         move.l    a0,men_f_1IV_txt
  6392.         add.l    #32,a0
  6393.         move.l    a0,men_f_1V_txt
  6394.         add.l    #32,a0
  6395.         move.l    a0,men_f_1VI_txt
  6396.         add.l    #32,a0
  6397.         move.l    a0,men_f_1VII_txt
  6398.         add.l    #32,a0
  6399.         move.l    a0,men_f_1VIII_txt
  6400.         add.l    #32,a0
  6401.         move.l    a0,men_f_1IX_txt
  6402.         add.l    #32,a0
  6403.         move.l    a0,men_f_1X_txt
  6404.  
  6405. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6406. ;        favourite menu item compositor exit
  6407. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6408.  
  6409. menu_favo_erro:    move.l    menu_favo_fl,d0
  6410.         beq.s    menu_favo_nof
  6411.         move.l    exec_base,a6
  6412.         move.l    d0,a1
  6413.         jsr    FreeVec(a6)
  6414.  
  6415. menu_favo_nof:    rts
  6416.  
  6417. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6418. ;        get cartridge name and path
  6419. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6420.  
  6421. get_cartridge_path_and_name:
  6422.         move.l    dir_n_name_ptr,a0
  6423.         moveq.l    #120/4-1,d0
  6424. load_colours_empty_buffer:
  6425.         clr.l    (a0)+
  6426.         dbra    d0,load_colours_empty_buffer
  6427.  
  6428.         move.l    dir_n_name_ptr,a0
  6429.         move.l    prefs_str_ptr,d0
  6430.         beq.s    load_colours_end_ok        ;empty field.
  6431.         move.l    d0,a1
  6432.         moveq.l    #120-1,d0
  6433.  
  6434. load_colours_copy_path:
  6435.         move.b    (a1)+,(a0)+
  6436.         beq.s    load_colours_end_of_path
  6437.         dbra    d0,load_colours_copy_path
  6438.  
  6439. load_colours_end_of_path:
  6440.         subq.l    #1,a0
  6441.  
  6442.         move.l    a0,d0
  6443.         cmp.l    dir_n_name_ptr,d0
  6444.         beq.s    load_colours_end_ok        ;no initial path.
  6445.  
  6446.         cmp.b    #"/",-1(a0)
  6447.         beq.s    load_colours_end_ok
  6448.         cmp.b    #":",-1(a0)
  6449.         beq.s    load_colours_end_ok
  6450.         move.b    #"/",(a0)+            ;fix the path.
  6451.  
  6452. load_colours_end_ok:
  6453.         bsr.b    copy_rom_name_to_a0
  6454.         rts
  6455.  
  6456. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6457. ;        copy rom name to a0
  6458. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6459.  
  6460. copy_rom_name_to_a0:
  6461.         move.l    cartridge,a1
  6462.         add.l    #$134,a1            ;input name.
  6463.         moveq.l    #16-1,d0
  6464. xopy_name_co:    move.b    (a1)+,d1
  6465.         bne.s    xopy_name_ok
  6466.         move.b    #" ",d1                ;0 => " ".
  6467. xopy_name_ok:    cmp.b    #"/",d1
  6468.         bne.s    xo_slash_fix
  6469.         move.b    #"-",d1                ;"/" => "-".
  6470. xo_slash_fix:    cmp.b    #$80,d1
  6471.         bne.s    xopy_mystery_fix
  6472.         move.b    #" ",d1
  6473. xopy_mystery_fix:
  6474.         move.b    d1,(a0)+
  6475.         dbra    d0,xopy_name_co
  6476.         rts
  6477.  
  6478. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6479. ;        turn on/off the obtain-gadget?
  6480. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6481.  
  6482. obtain_status:    subq.b    #1,obtain_status_counter
  6483.         bne.s    obtain_status_x
  6484.         move.b    #4,obtain_status_counter
  6485.  
  6486. obtain_status_direct:
  6487.         move.l    exec_base,a6
  6488.         jsr    Forbid(a6)
  6489.  
  6490.         lea    message_port_colour_editor_name,a1
  6491.         jsr    FindPort(a6)
  6492.         move.l    d0,message_port_colour_editor
  6493.         jsr    Permit(a6)
  6494.  
  6495.         tst.l    message_port_colour_editor
  6496.         bne.s    obtain_on
  6497.  
  6498. obtain_off:    tst.l    obtain_gadget_status
  6499.         bne.s    obtain_status_x
  6500.  
  6501.         cmp.l    #"GFX!",function_status
  6502.         bne.s    obtain_status_x
  6503.  
  6504.         move.l    intuition_base,a6
  6505.         move.l    gfx_g_obtain,a0
  6506.         move.l    function_ptr,a1
  6507.         sub.l    a2,a2
  6508.         jsr    OffGadget(a6)
  6509.  
  6510.         move.l    #1,obtain_gadget_status
  6511. obtain_status_x:rts
  6512.  
  6513. obtain_on:    tst.l    obtain_gadget_status
  6514.         beq.s    obtain_status_on_get_message
  6515.  
  6516.         cmp.l    #"GFX!",function_status
  6517.         bne.s    obtain_status_on_get_message
  6518.  
  6519.         move.l    intuition_base,a6
  6520.         move.l    gfx_g_obtain,a0
  6521.         move.l    function_ptr,a1
  6522.         sub.l    a2,a2
  6523.         jsr    OnGadget(a6)
  6524.  
  6525.         clr.l    obtain_gadget_status
  6526. obtain_status_on_get_message:
  6527.         move.l    exec_base,a6
  6528.         move.l    message_port,a0
  6529.         jsr    GetMsg(a6)
  6530.         tst.l    d0
  6531.         beq.s    obtain_status_on_x
  6532.  
  6533.         move.l    LN_NAME(a0),a1
  6534.         move.l    d0,a0
  6535.         move.l    MN_REPLYPORT(a0),d1
  6536.         cmp.l    message_port_colour_editor,d1
  6537.         beq.s    send_new_colours
  6538.         cmp.l    message_port,d1
  6539.         beq.s    obtain_new_colours
  6540.  
  6541. obtain_status_reply:
  6542.         move.l    a0,a1
  6543.         jsr    ReplyMsg(a6)            ;send the colours back.
  6544.  
  6545. obtain_status_on_x:
  6546.         rts
  6547.  
  6548. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6549. ;        send new colours
  6550. ;        INPUT:
  6551. ;        a0    = message.
  6552. ;        a1    = data area (256.B).
  6553. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6554.  
  6555. send_new_colours:
  6556.         lea    gameboy_colours,a2
  6557.         moveq.l    #8-1,d0
  6558.         lea    (MN_LENGTH+2)(a0),a3
  6559. copy_colours_data:
  6560.         move.l    (a2)+,d1
  6561.         move.b    d1,2(a3)
  6562.         lsr.l    #8,d1
  6563.         move.b    d1,1(a3)
  6564.         lsr.w    #8,d1
  6565.         move.b    d1,(a3)
  6566.         addq.l    #3,a3
  6567.         dbra    d0,copy_colours_data
  6568.  
  6569.         move.l    a0,a1
  6570.         jsr    ReplyMsg(a6)            ;send the colours back.
  6571.         rts
  6572.  
  6573. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6574. ;        obtain new colours
  6575. ;        INPUT:
  6576. ;        a0    = message.
  6577. ;        a1    = data area (256.B).
  6578. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6579.  
  6580. obtain_new_colours:
  6581.         lea    gameboy_colours,a2
  6582.         moveq.l    #8-1,d0
  6583.         moveq.l    #0,d1
  6584.         lea    (MN_LENGTH+2)(a0),a3
  6585. obtain_colours_data:
  6586.         move.b    (a3)+,d1
  6587.         lsl.w    #8,d1
  6588.         move.b    (a3)+,d1
  6589.         lsl.l    #8,d1
  6590.         move.b    (a3)+,d1
  6591.         move.l    d1,(a2)+
  6592.         dbra    d0,obtain_colours_data
  6593.  
  6594. obtain_colours_apply:
  6595.         lea    pen_list,a4
  6596.         move.l    (a4),pen_storage_list        ;save the pens.
  6597.         move.l    4(a4),pen_storage_list+4        
  6598.  
  6599.         lea    gameboy_colours,a3
  6600.         move.l    pub_screen_lock,a5
  6601.         lea    sc_ViewPort(a5),a5
  6602.         move.l    vp_ColorMap(a5),a5
  6603.         move.l    graphics_base,a6
  6604.         moveq.l    #8-1,d7
  6605.  
  6606. obtain_change_pens:
  6607.         moveq.l    #0,d0
  6608.         move.b    (a4),d0
  6609.         move.l    a5,a0
  6610.         jsr    ReleasePen(a6)
  6611.  
  6612.         lea    obtain_pens_tag_list,a1
  6613.         moveq.l    #0,d1
  6614.         moveq.l    #0,d2
  6615.         moveq.l    #0,d3
  6616.         move.b    1(a3),d1
  6617.         move.b    2(a3),d2
  6618.         move.b    3(a3),d3
  6619.         ror.l    #8,d1
  6620.         ror.l    #8,d2
  6621.         ror.l    #8,d3
  6622.         move.l    a5,a0
  6623.         jsr    ObtainBestPenA(a6)
  6624.         move.b    d0,(a4)+
  6625.         addq.l    #4,a3
  6626.         dbra    d7,obtain_change_pens
  6627.  
  6628.         move.l    pen_list,d0
  6629.         cmp.l    pen_storage_list,d0
  6630.         bne.s    convert_all_pens        ;pen(s) have changed.
  6631.         move.l    pen_list+4,d0
  6632.         cmp.l    pen_storage_list+4,d0
  6633.         bne.s    convert_all_pens
  6634.         rts                    ;no conversion.
  6635.  
  6636. convert_all_pens:
  6637.         move.l    gfx_game_still_array,a0
  6638.         move.l    gfx_game_still_tmp_array,a1
  6639.         lea    pen_list,a2
  6640.         move.w    #(304*39)-1,d0
  6641.         moveq.l    #0,d1
  6642. convert_pen_values:
  6643.         move.b    (a0)+,d1
  6644.         move.b    (a2,d1.l),(a1)+
  6645.         dbra    d0,convert_pen_values
  6646.  
  6647.         bsr.b    write_test_image
  6648.  
  6649. no_obtained_output:
  6650.         rts
  6651.  
  6652. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6653. ;        output the test image
  6654. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6655.  
  6656. write_test_image:
  6657.         cmp.l    #"GFX!",function_status
  6658.         bne.s    write_test_image_exit
  6659.  
  6660.         tst.l    cyber_base
  6661.         bne.s    write_test_image_with_cyber
  6662.  
  6663.         move.l    graphics_base,a6
  6664.         move.l    #34,d0
  6665.         move.l    #139,d1
  6666.         move.l    #34+303,d2
  6667.         move.l    #139+38,d3
  6668.         move.l    function_ptr,a0
  6669.         move.l    wd_RPort(a0),a0
  6670.         move.l    gfx_game_still_tmp_rast_port,a1
  6671.         move.l    gfx_game_still_tmp_array,a2
  6672.         jsr    WritePixelArray8(a6)
  6673.  
  6674. write_test_image_exit:
  6675.         rts
  6676.  
  6677. write_test_image_with_cyber:
  6678.         move.l    cyber_base,a6
  6679.         move.l    gfx_game_still_tmp_array,a0
  6680.         moveq.l    #0,d0
  6681.         moveq.l    #0,d1
  6682.         move.l    #304,d2
  6683.         moveq.l    #34,d3
  6684.         move.l    #139,d4
  6685.         move.l    #304,d5
  6686.         moveq.l    #39,d6
  6687.         move.l    #RECTFMT_LUT8,d7
  6688.         move.l    function_ptr,a1
  6689.         move.l    wd_RPort(a1),a1
  6690.         jsr    WritePixelArray(a6)
  6691.         rts
  6692.  
  6693. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6694. ;        back pattern the function window
  6695. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6696.  
  6697. back_pattern_function:
  6698.         move.l    graphics_base,a6
  6699.         move.l    back_pattern_map_attr,a0    ;a0 = source bitmap.
  6700.         move.l    function_ptr,a1
  6701.         move.l    wd_RPort(a1),a1            ;a1 = destination rastport.
  6702.         moveq.l    #0,d0                ;org x.
  6703.         moveq.l    #0,d1                ;org y.
  6704.         moveq.l    #0,d2                ;dst x.
  6705.         moveq.l    #0,d3                ;dst y.
  6706.         move.l    #function_x,d4            ;size x.
  6707.         sub.l    window_bars_width,d4
  6708.         move.l    #function_y-2,d5        ;size y.
  6709.         move.l    #$c0,d6                ;minterm.
  6710.         jsr    BltBitMapRastPort(a6)        ;update the screen window.
  6711.         rts
  6712.  
  6713. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6714. ;        draw a set of bevel boxes
  6715. ;        INPUT:
  6716. ;        a4    = window pointer.
  6717. ;        a5    = bevel box list.
  6718. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6719.  
  6720. draw_bevel_list:move.w    (a5)+,d0            ;x.
  6721.         beq.s    draw_bevel_end
  6722.         move.w    (a5)+,d1            ;y.
  6723.         move.w    (a5)+,d2            ;dx.
  6724.         move.w    (a5)+,d3            ;dy.
  6725.         move.l    a4,a0
  6726.         bsr.b    draw_bevel_box
  6727.         bra.s    draw_bevel_list
  6728. draw_bevel_end:    rts
  6729.  
  6730. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6731. ;        draw a bevel box
  6732. ;        INPUT:
  6733. ;        d0    = x.
  6734. ;        d1    = y.
  6735. ;        d2    = dx.
  6736. ;        d3    = dy.
  6737. ;        a0    = window pointer.
  6738. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6739.  
  6740. draw_bevel_box:    move.l    gad_tools_base,a6
  6741.         movem.l    d0-d3/a0,-(SP)
  6742.  
  6743.         move.l    wd_RPort(a0),a0
  6744.         lea    bevel_box_tags,a1
  6745.         move.l    visual_info,4(a1)
  6746.         jsr    DrawBevelBoxA(a6)
  6747.  
  6748.         movem.l    (SP)+,d0-d3/a0
  6749.         movem.l    d0-d3/a0,-(SP)
  6750.  
  6751.         move.l    wd_RPort(a0),a0
  6752.         addq.l    #1,d0
  6753.         addq.l    #1,d1
  6754.         subq.l    #2,d2
  6755.         subq.l    #2,d3
  6756.         lea    bevel_box_tagz,a1
  6757.         move.l    visual_info,4(a1)
  6758.         jsr    DrawBevelBoxA(a6)
  6759.  
  6760.         move.l    graphics_base,a6
  6761.         movem.l    (SP)+,d0-d3/a0
  6762.  
  6763.         move.l    wd_RPort(a0),a1
  6764.         add.l    d0,d2
  6765.         add.l    d1,d3
  6766.         addq.l    #2,d0
  6767.         addq.l    #2,d1
  6768.         subq.l    #3,d2
  6769.         subq.l    #3,d3
  6770.         jsr    EraseRect(a6)
  6771.         rts
  6772.  
  6773. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6774. ;        install gadgets
  6775. ;        INPUT:
  6776. ;        a1    = pointer to the first gadget of the list.
  6777. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6778.  
  6779. gadgets_ins:    move.l    a1,function_gad
  6780.  
  6781.         move.l    intuition_base,a6
  6782.         move.l    function_ptr,a0
  6783.         sub.l    a2,a2
  6784.         moveq.l    #-1,d0                ;position.
  6785.         moveq.l    #-1,d1
  6786.         jsr    AddGList(a6)
  6787.  
  6788.         move.l    function_gad,a0
  6789.         move.l    function_ptr,a1
  6790.         sub.l    a2,a2
  6791.         moveq.l    #-1,d0                ;all gadgets.
  6792.         jsr    RefreshGList(a6)
  6793.  
  6794.         move.l    gad_tools_base,a6
  6795.         move.l    function_ptr,a0
  6796.         sub.l    a1,a1
  6797.         jsr    GT_RefreshWindow(a6)
  6798.         rts
  6799.  
  6800. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6801. ;        output data to function window
  6802. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6803.  
  6804. function_window_output:
  6805.         moveq.l    #1,d0
  6806.  
  6807.         tst.l    function_ptr
  6808.         bne.s    function_window_output_exit
  6809.  
  6810.         move.l    intuition_base,a6
  6811.         lea    function_window,a0
  6812.         lea    win_tags_u,a1            ;universal taglist.
  6813.         jsr    OpenWindowTagList(a6)        ;structure and open the window.
  6814.         move.l    d0,function_ptr
  6815.         bne.s    function_window_output_exit
  6816.  
  6817.         lea    status_cant_open_window_txt,a5
  6818.         bsr.w    print_status_middle
  6819.         moveq.l    #0,d0
  6820.  
  6821. function_window_output_exit:
  6822.         rts
  6823.  
  6824. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6825. ;        remove gadgets
  6826. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6827.  
  6828. gadgets_rmv:    move.l    function_ptr,d0
  6829.         beq.s    gadgets_rmv_exit
  6830.         move.l    function_gad,d1
  6831.         beq.s    gadgets_rmv_x
  6832.  
  6833.         move.l    d0,a0
  6834.         move.l    d1,a1
  6835.         moveq.l    #-1,d0                ;all gadgets.
  6836.         move.l    intuition_base,a6
  6837.         jsr    RemoveGList(a6)
  6838.  
  6839.         clr.l    function_gad
  6840.         clr.l    function_jmp
  6841.  
  6842. gadgets_rmv_x:    move.l    graphics_base,a6
  6843.         move.l    function_ptr,a1
  6844.         move.l    wd_RPort(a1),a1
  6845.         moveq.l    #0,d0
  6846.         moveq.l    #0,d1
  6847.         move.l    #function_x,d2
  6848.         sub.l    window_bars_width,d2
  6849.         move.l    #function_y-2-11,d3
  6850.         jsr    EraseRect(a6)
  6851.  
  6852. gadgets_rmv_exit:
  6853.         rts
  6854.  
  6855. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6856. ;        open ahi
  6857. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6858.  
  6859.  
  6860. open_ahi:    move.l    exec_base,a6
  6861.         jsr    CreateMsgPort(a6)
  6862.  
  6863.         move.l    d0,ahi_port
  6864.         beq.b    ahi_error
  6865.  
  6866.         move.l    d0,a0
  6867.         move.l    #AHIRequest_SIZEOF,d0
  6868.         jsr    CreateIORequest(a6)
  6869.  
  6870.         move.l    d0,ahi_ior
  6871.         beq.b    ahi_error
  6872.  
  6873.         lea    ahi_name,a0
  6874.         move.l    d0,a1
  6875.         clr.w    ahir_Version(a1)        ;all versions are fine!
  6876.         move.l    #AHI_NO_UNIT,d0
  6877.         moveq.l    #0,d1
  6878.         jsr    OpenDevice(a6)
  6879.  
  6880.         move.l    d0,ahi_device
  6881.         bne.b    ahi_error
  6882.  
  6883.         move.l    ahi_ior,a0
  6884.         move.l    IO_DEVICE(a0),d0
  6885.         rts
  6886.  
  6887. ahi_error:    moveq.l    #0,d0
  6888.         rts
  6889.  
  6890. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6891. ;        close ahi
  6892. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6893.  
  6894.  
  6895. close_ahi:    move.l    ahi_base,d0
  6896.         beq.s    no_ahi_req
  6897.         move.l    d0,a6
  6898.         move.l    ahi_request,d0
  6899.         beq.s    no_ahi_req
  6900.         move.l    d0,a0
  6901.         jsr    AHI_FreeAudioRequest(a6)
  6902.  
  6903. no_ahi_req:    move.l    exec_base,a6
  6904.         tst.l    ahi_device
  6905.         beq.s    ahi_close_nd
  6906.  
  6907.         move.l    ahi_ior,a1
  6908.         jsr    CloseDevice(a6)
  6909.  
  6910. ahi_close_nd:    move.l    ahi_ior,d0
  6911.         beq.s    ahi_no_ior
  6912.         move.l    d0,a0
  6913.         jsr    DeleteIORequest(a6)
  6914.  
  6915. ahi_no_ior:    move.l    ahi_port,d0
  6916.         beq.s    ahi_no_msg_port
  6917.         move.l    d0,a0
  6918.         jsr    DeleteMsgPort(a6)
  6919.  
  6920. ahi_no_msg_port:rts
  6921.  
  6922. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6923. ;        open ahi
  6924. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6925.  
  6926. turn_ahi_on:
  6927.  
  6928.         tst.b    snd_master
  6929.         bne.w    ahi_on_quit
  6930.  
  6931.         tst.l    ahi_base
  6932.         beq.w    ahi_on_quit
  6933.  
  6934.         move.b    $bfe001,old_led
  6935.  
  6936.         move.l    ahi_base,a6
  6937.         lea    ahi_alloc_tags,a1
  6938.         move.l    ahi_mode_id,4(a1)        ;use the selected settings.
  6939.         move.l    ahi_mix_freq,12(a1)
  6940.         jsr    AHI_AllocAudioA(a6)
  6941.         move.l    d0,ahi_audio_ctrl
  6942.         beq.w    ahi_on_quit
  6943.  
  6944.         bsr.w    init_the_samples
  6945.  
  6946. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6947. ;          audio inits
  6948. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6949.  
  6950.         move.l    exec_base,a6
  6951.         jsr    CacheClearU(a6)            ;clear caches.
  6952.  
  6953.         move.l    gb_mem_jumps,a0
  6954.         bsr.w    sound_init
  6955.  
  6956.         move.l    exec_base,a6
  6957.         jsr    CacheClearU(a6)            ;clear caches.
  6958.  
  6959.         cmp.b    #2,snd_quality
  6960.         beq.w    ahi_on_quit
  6961.  
  6962. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6963. ;        init the sound registers
  6964. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6965.  
  6966. init_the_sound_registers:
  6967.         move.l    gb_mem_jumps,a6
  6968.         move.l    gb_memory,a2
  6969.         move.l    #$ff26,d7
  6970.         move.w    #$26-$10,d5
  6971.  
  6972. normal_inits_loop_1:
  6973.         move.b    (a2,d7.l),d6
  6974.         movem.l    d5/d7/a6,-(SP)
  6975.  
  6976.         jsr    ([a6,d7.l*4])
  6977.  
  6978.         movem.l    (SP)+,d5/d7/a6
  6979.         subq.w    #1,d7
  6980.         dbra    d5,normal_inits_loop_1
  6981.  
  6982.         move.l    gb_mem_jumps,a6
  6983.         move.l    gb_memory,a2
  6984.         move.l    #$ff10,d7
  6985.         move.w    #$26-$10,d5
  6986.  
  6987. normal_inits_loop_2:
  6988.         move.b    (a2,d7.l),d6
  6989.         movem.l    d5/d7/a6,-(SP)
  6990.  
  6991.         jsr    ([a6,d7.l*4])
  6992.  
  6993.         movem.l    (SP)+,d5/d7/a6
  6994.         addq.w    #1,d7
  6995.         dbra    d5,normal_inits_loop_2
  6996.  
  6997.         move.l    gb_mem_jumps,a6
  6998.         move.l    gb_memory,a2
  6999.         move.l    #$ff30,d7
  7000.         move.w    #$3f-$30,d5
  7001.  
  7002. normal_inits_loop_3:
  7003.         move.b    (a2,d7.l),d6
  7004.         movem.l    d5/d7/a6,-(SP)
  7005.  
  7006.         jsr    ([a6,d7.l*4])
  7007.  
  7008.         movem.l    (SP)+,d5/d7/a6
  7009.         addq.w    #1,d7
  7010.         dbra    d5,normal_inits_loop_3
  7011.  
  7012. ahi_on_quit:
  7013.         rts
  7014.  
  7015. sound_init:
  7016.         add.l    #$ff00*4,a0
  7017.         lea    snd_master,a1
  7018.         lea    sound_routines,a2
  7019.  
  7020.         cmp.b    #2,snd_quality
  7021.         bne.s    normal_audio_decoding
  7022.         lea    sound_routines_for_y_driver,a2
  7023.  
  7024. normal_audio_decoding:
  7025.  
  7026. file_snd:
  7027.         tst.b    (a1)+
  7028.         bne.w    no_snd_init
  7029.  
  7030.         add.l    #$10*4,a0
  7031.         moveq.l  #0,d1
  7032.         moveq.l  #0,d2
  7033.  
  7034.         tst.b    (a1)+
  7035.         bne.s    no_I
  7036.  
  7037.         move.l   (a2),(a0)
  7038.         move.l   4(a2),4(a0)
  7039.         move.l   8(a2),8(a0)
  7040.         move.l   12(a2),12(a0)
  7041.         move.l   16(a2),16(a0)
  7042.         addq.b   #1,d1
  7043.  
  7044. no_I:   add.l    #20+4,a0
  7045.         add.l    #20,a2
  7046.         tst.b    (a1)+
  7047.         bne.s    no_II
  7048.  
  7049.         move.l    (a2),(a0)
  7050.         move.l    4(a2),4(a0)
  7051.         move.l    8(a2),8(a0)
  7052.         move.l    12(a2),12(a0)
  7053.         addq.b    #1,d1
  7054.  
  7055. no_II:  add.l    #16,a0
  7056.         add.l    #16,a2
  7057.         tst.b    (a1)+
  7058.         bne.s    no_III
  7059.  
  7060.         move.l    (a2),(a0)
  7061.         move.l    4(a2),4(a0)
  7062.         move.l    8(a2),8(a0)
  7063.         move.l    12(a2),12(a0)
  7064.         move.l    16(a2),16(a0)
  7065.         addq.b    #1,d1
  7066.         move.b    #1,d2
  7067.  
  7068. no_III: add.l    #20+4,a0
  7069.         add.l    #20,a2
  7070.         tst.b    (a1)
  7071.         bne.s    no_IV
  7072.  
  7073.         move.l    (a2),(a0)
  7074.         move.l    4(a2),4(a0)
  7075.         move.l    8(a2),8(a0)
  7076.         move.l    12(a2),12(a0)
  7077.         addq.b    #1,d1
  7078.  
  7079. no_IV:  add.l    #16,a0
  7080.         add.l    #16,a2
  7081.         tst.b    d1
  7082.         beq.s    no_V
  7083.  
  7084.         move.l    (a2),(a0)
  7085.         move.l    4(a2),4(a0)
  7086.         move.l    8(a2),8(a0)
  7087.  
  7088. no_V:   add.l    #12,a0
  7089.         add.l    #12,a2
  7090.         tst.b    d2
  7091.         beq.s    no_snd_init
  7092.  
  7093.     add.l    #9*4,a0
  7094.     move.l    (a2),d0
  7095.     move.l    d0,(a0)+
  7096.     move.l    d0,(a0)+
  7097.     move.l    d0,(a0)+
  7098.     move.l    d0,(a0)+
  7099.     move.l    d0,(a0)+
  7100.     move.l    d0,(a0)+
  7101.     move.l    d0,(a0)+
  7102.     move.l    d0,(a0)+
  7103.     move.l    d0,(a0)+
  7104.     move.l    d0,(a0)+
  7105.     move.l    d0,(a0)+
  7106.     move.l    d0,(a0)+
  7107.     move.l    d0,(a0)+
  7108.     move.l    d0,(a0)+
  7109.     move.l    d0,(a0)+
  7110.     move.l    d0,(a0)
  7111. no_snd_init:
  7112.                 rts
  7113.  
  7114. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7115. ;        init the samples
  7116. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7117.  
  7118.  
  7119. init_the_samples:
  7120.         tst.b    snd_chnlI
  7121.         bne.s    init_no_1
  7122.  
  7123.         move.l    smpl_info_I,a0
  7124.         move.l    #AHIST_M8S,ahisi_Type(a0)    ;type.
  7125.         move.l    smpl_mem_3,ahisi_Address(a0)    ;address.
  7126.         move.l    #8*512,ahisi_Length(a0)        ;size.
  7127.  
  7128.         move.l    ahi_base,a6
  7129.         moveq.l    #0,d0                ;sample number.
  7130.         move.l    #AHIST_SAMPLE,d1        ;type.
  7131.         move.l    smpl_info_I,a0            ;info field.
  7132.         move.l    ahi_audio_ctrl,a2        ;ctrl.
  7133.         jsr    AHI_LoadSound(a6)
  7134.  
  7135.         moveq.l    #0,d0                ;channel.
  7136.         moveq.l    #0,d1                ;sample.
  7137.         moveq.l    #0,d2                ;offset.
  7138.         move.l    #8*512,d3            ;size (full).
  7139.  
  7140.                 moveq.l #1,d4                           ;new faster variant.
  7141. ;        moveq.l    #0,d4
  7142. ;        bset    #AHISB_IMM,d4            ;flags.
  7143.         move.l    ahi_audio_ctrl,a2
  7144.         jsr    AHI_SetSound(a6)
  7145.  
  7146. init_no_1:    tst.b    snd_chnlII
  7147.         bne.s    init_no_2
  7148.  
  7149.         move.l    smpl_info_II,a0
  7150.         move.l    #AHIST_M8S,ahisi_Type(a0)    ;type.
  7151.         move.l    smpl_mem_3,ahisi_Address(a0)    ;address.
  7152.         move.l    #8*512,ahisi_Length(a0)        ;size.
  7153.  
  7154.         moveq.l    #1,d0                ;sample number.
  7155.         move.l    #AHIST_SAMPLE,d1        ;type.
  7156.         move.l    smpl_info_II,a0            ;info field.
  7157.         move.l    ahi_audio_ctrl,a2        ;ctrl.
  7158.         jsr    AHI_LoadSound(a6)
  7159.  
  7160.         moveq.l    #1,d0                ;channel.
  7161.         moveq.l    #1,d1                ;sample.
  7162.         moveq.l    #0,d2                ;offset.
  7163.         move.l    #8*512,d3            ;size (full).
  7164.  
  7165.                 moveq.l #1,d4
  7166. ;        moveq.l    #0,d4
  7167. ;        bset    #AHISB_IMM,d4            ;flags.
  7168.         move.l    ahi_audio_ctrl,a2
  7169.         jsr    AHI_SetSound(a6)
  7170.  
  7171. init_no_2:    tst.b    snd_chnlIII
  7172.         bne.s    init_no_3
  7173.  
  7174.         move.l    smpl_info_III,a0
  7175.         move.l    #AHIST_M8S,ahisi_Type(a0)    ;type.
  7176.         move.l    smpl_III_mem,ahisi_Address(a0)    ;address.
  7177.         move.l    #32,ahisi_Length(a0)        ;size.
  7178.  
  7179.         moveq.l    #2,d0                ;sample number.
  7180.         move.l    #AHIST_DYNAMICSAMPLE,d1        ;type.
  7181.         move.l    smpl_info_III,a0        ;info field.
  7182.         move.l    ahi_audio_ctrl,a2        ;ctrl.
  7183.         jsr    AHI_LoadSound(a6)
  7184.  
  7185.         moveq.l    #2,d0                ;channel.
  7186.         moveq.l    #2,d1                ;sample.
  7187.         moveq.l    #0,d2                ;offset.
  7188.         moveq.l    #32,d3                ;size (full).
  7189.  
  7190.                 moveq.l #1,d4
  7191. ;        moveq.l    #0,d4
  7192. ;        bset    #AHISB_IMM,d4            ;flags.
  7193.         move.l    ahi_audio_ctrl,a2
  7194.         jsr    AHI_SetSound(a6)
  7195.  
  7196. init_no_3:    tst.b    snd_chnlIV
  7197.         bne.s    init_no_4
  7198.  
  7199.         move.l    smpl_info_IV,a0
  7200.         move.l    #AHIST_M8S,ahisi_Type(a0)    ;type.
  7201.         move.l    #smpl_IV_bn,ahisi_Address(a0)    ;address.
  7202.         move.l    #256*4,ahisi_Length(a0)        ;size.
  7203.  
  7204.         moveq.l    #3,d0                ;sample number.
  7205.         move.l    #AHIST_SAMPLE,d1        ;type.
  7206.         move.l    smpl_info_IV,a0            ;info field.
  7207.         move.l    ahi_audio_ctrl,a2        ;ctrl.
  7208.         jsr    AHI_LoadSound(a6)
  7209.  
  7210.         moveq.l    #3,d0                ;channel.
  7211.         moveq.l    #3,d1                ;sample.
  7212.         moveq.l    #0,d2                ;offset.
  7213.         move.l    #256*4,d3            ;size (full).
  7214.  
  7215.                 moveq.l #1,d4
  7216. ;        moveq.l    #0,d4
  7217. ;        bset    #AHISB_IMM,d4            ;flags.
  7218.         move.l    ahi_audio_ctrl,a2
  7219.         jsr    AHI_SetSound(a6)
  7220.  
  7221. init_no_4:    lea    ahi_ctrl_tags_I,a1
  7222.         move.l    ahi_audio_ctrl,a2
  7223.         jsr    AHI_ControlAudioA(a6)
  7224. ;        tst.l    d0
  7225. ;        bne.s    ahi_error_I
  7226.         rts
  7227.  
  7228. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7229. ;        turn ahi off
  7230. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7231.  
  7232. turn_ahi_off:
  7233.  
  7234.         tst.b    snd_master
  7235.         bne.s    ahi_off_xit
  7236.  
  7237.         move.l    ahi_base,d0
  7238.         beq.s    ahi_off_xit
  7239.         move.l    d0,a6
  7240.  
  7241.         move.l    ahi_audio_ctrl,a2
  7242.         jsr    AHI_FreeAudio(a6)
  7243.  
  7244.         move.b    old_led,d1
  7245.         and.b    #%10,d1
  7246.         move.b    $bfe001,d0
  7247.         and.b    #%11111101,d0
  7248.         or.b    d1,d0
  7249.         move.b    d0,$bfe001
  7250.  
  7251. ahi_off_xit:    rts
  7252.  
  7253. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7254. ;        print a status text into the middle of a rastport
  7255. ;        INPUT:
  7256. ;        a5    = the text.
  7257. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7258.  
  7259. print_status_middle:
  7260.         bsr.b    print_status_middle_erase
  7261.         bsr.b    print_status_middle_new
  7262.         rts
  7263.  
  7264. print_status_middle_erase:
  7265.         move.l    old_status_text,d0
  7266.         beq.s    print_status_middle_erase_exit
  7267.         lea    emulator_status_text,a4
  7268.         move.l    d0,emulator_status_txt
  7269.         clr.b    (a4)                ;clear the old text.
  7270.         bsr.b    print_status_middle_do
  7271.  
  7272. print_status_middle_erase_exit:
  7273.         rts
  7274.  
  7275. print_status_middle_new:
  7276.         move.l    a5,old_status_text
  7277.         move.l    a5,emulator_status_txt
  7278.         lea    emulator_status_text,a4
  7279.         move.b    #1,(a4)
  7280.         bsr.b    print_status_middle_do
  7281.         rts
  7282.  
  7283. print_status_middle_do:
  7284.         move.l    intuition_base,a6
  7285.         move.l    a4,a0
  7286.         jsr    IntuiTextLength(a6)
  7287.  
  7288.         move.l    #menu_x,d1
  7289.         sub.l    d0,d1
  7290.         lsr.l    #1,d1
  7291.         move.l    d1,d0                ;new x.
  7292.  
  7293.         move.l    menu_ptr,a0
  7294.         move.l    wd_RPort(a0),a0
  7295.         move.l    a4,a1
  7296.         moveq.l    #0,d1
  7297.         jsr    PrintIText(a6)            ;print it.
  7298.         rts
  7299.  
  7300. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7301. ;        print a text into the middle of a rastport
  7302. ;        INPUT:
  7303. ;        a0    = the text.
  7304. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7305.  
  7306. print_middle:    move.l    intuition_base,a6
  7307.         move.l    a0,a3
  7308.         jsr    IntuiTextLength(a6)
  7309.  
  7310.         move.l    #function_x,d1
  7311.         sub.l    d0,d1
  7312.         lsr.l    #1,d1
  7313.         move.l    d1,d0                ;new x.
  7314.  
  7315.         move.l    function_ptr,a0
  7316.         move.l    wd_RPort(a0),a0
  7317.         move.l    a3,a1
  7318.         moveq.l    #0,d1
  7319.         jsr    PrintIText(a6)            ;print it.
  7320.         rts
  7321.  
  7322. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7323. ;        sort the xpk packer sub library names and create
  7324. ;        a system list structure for the gadtools list gadget
  7325. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7326.  
  7327. sort_xpk_names:    move.l    xpk_names_v,d0
  7328.         subq.w    #1,d0
  7329.         ble.s    sort_do_list
  7330.  
  7331.         subq.w    #1,d0
  7332. sort_xpk_names_bubble:
  7333.         move.w    d0,d1
  7334.         subq.w    #1,d1
  7335.         blt.s    sort_xpk_names_last_bubble
  7336.         move.l    xpk_names,a0
  7337.         lea    4(a0),a1
  7338. sort_xpk_names_sweep:
  7339.         move.l    (a0),d2
  7340.         cmp.l    (a1),d2
  7341.         blt.s    sort_xpk_names_no_swap
  7342.         move.l    (a1),(a0)
  7343.         move.l    d2,(a1)
  7344. sort_xpk_names_no_swap:
  7345.         addq.l    #4,a0
  7346.         addq.l    #4,a1
  7347.         dbra    d1,sort_xpk_names_sweep
  7348.         dbra    d0,sort_xpk_names_bubble
  7349.         bra.s    sort_do_list
  7350.  
  7351. sort_xpk_names_last_bubble:
  7352.         move.l    xpk_names,a0
  7353.         lea    4(a0),a1
  7354. sort_xpk_names_last_sweep:
  7355.         move.l    (a0),d2
  7356.         cmp.l    (a1),d2
  7357.         blt.s    sort_xpk_names_last_no_swap
  7358.         move.l    (a1),(a0)
  7359.         move.l    d2,(a1)
  7360. sort_xpk_names_last_no_swap:
  7361.  
  7362. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7363. ;        create list structure
  7364. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7365.  
  7366. sort_do_list:
  7367.  
  7368. xpk:         move.l    xpk_names_v,d0
  7369.         beq.w    sort_do_no_names
  7370.  
  7371.         move.l    exec_base,a6
  7372.         move.l    #LN_SIZE+2,d1
  7373.         mulu.w    d1,d0
  7374.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1    ;the system flags.
  7375.         jsr    AllocVec(a6)
  7376.         move.l    d0,xpk_names_list        ;the pointer here.
  7377.         beq.w    sort_do_err
  7378.  
  7379.         move.l    xpk_names_v,d0
  7380.         lsl.l    #3,d0
  7381.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1    ;the system flags.
  7382.         jsr    AllocVec(a6)
  7383.         move.l    d0,xpk_names_all        ;the pointer here.
  7384.         beq.w    sort_do_err
  7385.  
  7386. sort_do_list_d:    move.l    xpk_names,a0            ;.L names.
  7387.         move.l    xpk_names_list,a1        ;list structure.
  7388.         move.l    xpk_names_all,a2        ;names.
  7389.         move.l    xpk_label_list,a6
  7390.  
  7391.         move.l    a1,LH_HEAD(a6)
  7392.         move.l    a6,LN_PRED(a1)
  7393.  
  7394.         move.l    #LN_SIZE+2,d1
  7395.         move.l    xpk_names_v,d0
  7396.         sub.l    a3,a3
  7397.         subq.w    #1,d0
  7398.         beq.s    sort_do_list_ln            ;only one node.
  7399.  
  7400. sort_do_list_c:    move.l    (a0)+,(a2)            ;do the first node.
  7401.         clr.b    4(a2)
  7402.         move.l    a2,LN_NAME(a1)
  7403.         lea    (a1,d1.l),a3
  7404.         move.l    a3,LN_SUCC(a1)
  7405.         move.l    a1,a3
  7406.         addq.l    #8,a2                ;next name.
  7407.         add.l    d1,a1                ;     node.
  7408.         subq.w    #1,d0
  7409.         beq.s    sort_do_list_ln            ;to last node.
  7410.         subq.w    #1,d0
  7411.  
  7412. sort_do_list_g:    move.l    (a0)+,(a2)
  7413.         clr.b    4(a2)
  7414.         move.l    a2,LN_NAME(a1)
  7415.         move.l    a3,LN_PRED(a1)
  7416.         lea    (a1,d1.l),a3
  7417.         move.l    a3,LN_SUCC(a1)
  7418.         move.l    a1,a3
  7419.         addq.l    #8,a2                ;next name.
  7420.         add.l    d1,a1                ;     node.
  7421.         dbra    d0,sort_do_list_g        ;         .
  7422.  
  7423. sort_do_list_ln:move.l    (a0),(a2)            ;do the last node.
  7424.         clr.b    4(a2)
  7425.         move.l    a2,LN_NAME(a1)
  7426.         move.l    a3,LN_PRED(a1)
  7427.  
  7428.         move.l    a1,LH_TAILPRED(a6)
  7429.         lea    LH_TAIL(a6),a5
  7430.         move.l    a5,LN_SUCC(a1)
  7431.  
  7432. sort_do_x:    moveq.l    #0,d0
  7433.         rts
  7434.  
  7435. sort_do_err:    moveq.l    #1,d0
  7436.         rts
  7437.  
  7438. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7439. ;        no xpk sub library names
  7440. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7441.  
  7442. sort_do_no_names:
  7443.         move.l    exec_base,a6
  7444.         move.l    #LN_SIZE+2,d0
  7445.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1    ;the system flags.
  7446.         jsr    AllocVec(a6)
  7447.         move.l    d0,xpk_names_list        ;the pointer here.
  7448.         beq.w    sort_do_err
  7449.  
  7450.         moveq.l    #8,d0
  7451.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1    ;the system flags.
  7452.         jsr    AllocVec(a6)
  7453.         move.l    d0,xpk_names_all        ;the pointer here.
  7454.         beq.w    sort_do_err
  7455.  
  7456.         move.l    xpk_names_list,a1        ;list structure.
  7457.         move.l    xpk_names_all,a2        ;names.
  7458.         move.l    xpk_label_list,a6
  7459.  
  7460.         move.l    a1,LH_HEAD(a6)
  7461.         move.l    a6,LN_PRED(a1)
  7462.  
  7463.         move.w    #"N/",(a2)            ;do the last node.
  7464.         move.b    #"A",2(a2)
  7465.         clr.b    3(a2)
  7466.         move.l    a2,LN_NAME(a1)
  7467.  
  7468.         move.l    a1,LH_TAILPRED(a6)
  7469.         lea    LH_TAIL(a6),a5
  7470.         move.l    a5,LN_SUCC(a1)
  7471.  
  7472.         moveq.l    #0,d0
  7473.         rts
  7474.  
  7475. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7476. ;        the pen .W remapping table generator
  7477. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7478.  
  7479. do_pen_table:    cmp.b    #2,old_render
  7480.         bne.s    do_pen_table_exit
  7481.  
  7482.         lea    pen_list,a0
  7483.         lea    gameboy_colours_conversion_table,a1
  7484.         move.l    (a0)+,(a1)+
  7485.         move.b    (a0)+,d0
  7486.         move.b    d0,(a1)+
  7487.         move.b    d0,(a1)+
  7488.         move.b    d0,(a1)+
  7489.         move.b    d0,(a1)+
  7490.         move.b    (a0)+,d0
  7491.         move.b    d0,(a1)+
  7492.         move.b    d0,(a1)+
  7493.         move.b    d0,(a1)+
  7494.         move.b    d0,(a1)+
  7495.         move.b    (a0)+,d0
  7496.         move.b    d0,(a1)+
  7497.         move.b    d0,(a1)+
  7498.         move.b    d0,(a1)+
  7499.         move.b    (a0),(a1)
  7500.  
  7501.         move.b    #%11100100,back_ground_colour_byte
  7502.  
  7503.         lea    gameboy_colours_conversion_table,a0
  7504.         move.l    pen_conversion_table,a1
  7505.         moveq.l    #16-1,d0
  7506.         moveq.l    #0,d3
  7507. do_conversion_table:
  7508.         moveq.l    #16-1,d1
  7509. do_conversion_table_copy:
  7510.         move.b    (a0,d0.l),d2
  7511.         lsl.w    #8,d2
  7512.         move.b    (a0,d1.l),d2
  7513.         move.b    d0,d3
  7514.         lsl.w    #8,d3
  7515.         move.b    d1,d3
  7516.         move.w    d2,(a1,d3.l*2)
  7517.         ror.w    #8,d2
  7518.         ror.w    #8,d3
  7519.         move.w    d2,(a1,d3.l*2)
  7520.         dbra    d1,do_conversion_table_copy
  7521.         dbra    d0,do_conversion_table
  7522.  
  7523.         bsr.w    update_bg_pal
  7524.  
  7525.         move.l    exec_base,a6
  7526.         jsr    CacheClearU(a6)            ;clear caches.
  7527.  
  7528. do_pen_table_exit:
  7529.  
  7530.         rts
  7531.  
  7532. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7533. ;        the x flip table generator
  7534. ;        TABLE:
  7535. ;        .W    = flipped data (.B plane 0, .B plane 1).
  7536. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7537.  
  7538. do_x_flip_t:    move.l    x_flip_table,a0            ;input
  7539.         move.l    #$10000,d0            ;this many (!).
  7540.  
  7541.         moveq.l    #0,d1                ;d1 = the input word.
  7542. do_x_flip:    move.b    d1,d2
  7543.         bsr.b    flip_x_byte            ;flip d2.B.
  7544.         lsl.w    #8,d2                ;right byte left.
  7545.         ror.w    #8,d1                ;left byte right.
  7546.         move.b    d1,d2                ;d2 = x-flipped.B, left.B.
  7547.         bsr.b    flip_x_byte            ;flip d2.B.
  7548.         ror.w    #8,d2                ;move to the normal order.
  7549.         rol.w    #8,d1                ;move to the normal order.
  7550.         move.w    d2,(a0)+            ;store the flipped word.
  7551.  
  7552.         addq.w    #1,d1                ;next entry.
  7553.         subq.l    #1,d0
  7554.         bne.s    do_x_flip            ;next entry.
  7555.         rts                    ;exit.
  7556.  
  7557. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7558. ;        the x byte flipper
  7559. ;        INPUT:
  7560. ;        a0    = RESERVED!
  7561. ;        d0    = RESERVED!
  7562. ;        d1    = RESERVED!
  7563. ;        d2    = input.B, otherwise RESERVED!
  7564. ;        OUTPUT:
  7565. ;        d2    = output.B, otherwise RESERVED!
  7566. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7567.  
  7568. flip_x_byte:    move.b    d2,d3
  7569.         and.b    #%1,d2
  7570.         ror.b    #1,d2                ;%0000000x done.
  7571.  
  7572.         move.b    d3,d4
  7573.         and.b    #%10,d4
  7574.         ror.b    #3,d4
  7575.         add.b    d4,d2                ;%000000x0 done.
  7576.  
  7577.         move.b    d3,d4
  7578.         and.b    #%100,d4
  7579.         rol.b    #3,d4
  7580.         add.b    d4,d2                ;%00000x00 done.
  7581.  
  7582.         move.b    d3,d4
  7583.         and.b    #%1000,d4
  7584.         rol.b    #1,d4
  7585.         add.b    d4,d2                ;%0000x000 done.
  7586.  
  7587.         move.b    d3,d4
  7588.         and.b    #%10000,d4
  7589.         ror.b    #1,d4
  7590.         add.b    d4,d2                ;%000x0000 done.
  7591.  
  7592.         move.b    d3,d4
  7593.         and.b    #%100000,d4
  7594.         ror.b    #3,d4
  7595.         add.b    d4,d2                ;%00x00000 done.
  7596.  
  7597.         move.b    d3,d4
  7598.         and.b    #%1000000,d4
  7599.         rol.b    #3,d4
  7600.         add.b    d4,d2                ;%0x000000 done.
  7601.  
  7602.         and.b    #%10000000,d3
  7603.         rol.b    #1,d3
  7604.         add.b    d3,d2                ;%x0000000 done.
  7605.         rts
  7606.  
  7607. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7608. ;        open a specified file
  7609. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7610.  
  7611. load_rom:    move.l    req_tools_base,a6
  7612.         lea    req_tags,a0            ;the tags.
  7613.         move.l    menu_ptr,4(a0)            ;the position pointer.
  7614.         move.l    request_ptr_lo,a1        ;the requester pointer.
  7615.         move.l    name_ptr,a2            ;the output area.
  7616.         lea    request_load,a3            ;the title text.
  7617.         jsr    rtFileRequestA(a6)        ;open a file requester.
  7618.  
  7619. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7620. ;        use this directory as the new default dir for
  7621. ;        cartridge loading
  7622. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7623.  
  7624. load_load_cart:    move.l    request_ptr_lo,a2        ;directory.
  7625.         move.l    rtfi_Dir(a2),a2
  7626.         move.l    def_dir,a0
  7627.         bsr.w    memorize_dir            ;memorize the dir.
  7628.  
  7629.         tst.l    d0                ;from the requester.
  7630.         beq.w    load_error_not_selected        ;error! none selected!
  7631.  
  7632. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7633. ;        save the old cartridge's battery ram
  7634. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7635.  
  7636.         bsr.w    save_battery_ram
  7637.  
  7638. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7639. ;        copy the directory and name to a single array and
  7640. ;        test if the file really exists
  7641. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7642.  
  7643.         move.l    request_ptr_lo,a2        ;directory.
  7644.         bsr.w    parse_req_name
  7645.  
  7646.         tst.b    load_menu_tag            ;an old name load?
  7647.         bne.s    cli_load_here            ;yes. from the menu list.
  7648.  
  7649.         move.l    dos_base,a6
  7650.         move.l    dir_n_name_ptr,d1        ;the name.
  7651.         moveq.l    #ACCESS_READ,d2
  7652.         jsr    Lock(a6)
  7653.         move.l    d0,d1
  7654.         beq.s    cli_load_here            ;skip the menu adding part
  7655.  
  7656.         jsr    UnLock(a6)            ;unlock it. all is well!
  7657.  
  7658. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7659. ;        now copy the cartridge name into the menu field
  7660. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7661.  
  7662.         move.l    prefs_file,a0
  7663.         add.l    #560+32*18,a0            ;to name fields.
  7664.         lea    32(a0),a1            ;the last entry.
  7665.         moveq.l    #19-1,d0
  7666. roll_names:    move.l    (a0)+,(a1)+
  7667.         move.l    (a0)+,(a1)+
  7668.         move.l    (a0)+,(a1)+
  7669.         move.l    (a0)+,(a1)+
  7670.         move.l    (a0)+,(a1)+
  7671.         move.l    (a0)+,(a1)+
  7672.         move.l    (a0)+,(a1)+
  7673.         move.l    (a0),(a1)            ;32 bytes.
  7674.         sub.l    #28+32,a0
  7675.         sub.l    #28+32,a1
  7676.         dbra    d0,roll_names
  7677.  
  7678.         move.l    name_ptr,a2            ;name.
  7679.         moveq.l    #31-1,d0
  7680. copy_name_1st:    move.b    (a2)+,(a1)+
  7681.         dbra    d0,copy_name_1st
  7682.         clr.b    (a1)
  7683.  
  7684.         move.l    intuition_base,a6
  7685.         move.l    menu_ptr,a0
  7686.         jsr    ClearMenuStrip(a6)        ;clear menus.
  7687.  
  7688.         move.l    menu_ptr,a0
  7689.         lea    menu_recent,a1
  7690.         jsr    SetMenuStrip(a6)        ;add menus.
  7691.  
  7692. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7693. ;        find out if the file can be unpacked with xpk master
  7694. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7695.  
  7696. cli_load_here:    move.l    xpk_master_base,d0
  7697.         beq.w    no_xpk_open
  7698.         move.l    d0,a6
  7699.         lea    xfh_pointer,a0
  7700.         lea    xpk_in_tags,a1
  7701.         move.l    dir_n_name_ptr,4(a1)
  7702.         jsr    XpkOpen(a6)
  7703.         tst.l    d0
  7704.         bne.w    no_xpk_open
  7705.  
  7706.         bsr.w    get_packer_name
  7707.  
  7708.         move.l    xfh_pointer,a0            ;a0 = xpkfib structure.
  7709.         move.l    xf_Type(a0),d0            ;d0 = file type.
  7710.         cmp.l    #XPKTYPE_PACKED,d0        ;is it packed?
  7711.         bne.w    quit_xpk            ;no. it's something else.
  7712.  
  7713.         move.l    xf_ULen(a0),file_length        ;uncompressed length.
  7714.         add.l    #XPK_MARGIN,file_length        ;xpk margin area.
  7715.  
  7716. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7717. ;        allocate memory
  7718. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7719.  
  7720.         bsr.w    alloc_cart_mem            ;allocate memory for
  7721.                             ;the cartridge.
  7722.         tst.l    d7
  7723.         beq.w    quit_xpk_e_mem            ;not enough! quit.
  7724.  
  7725. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7726. ;        unpack the rom image
  7727. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7728.  
  7729.         move.l    xpk_master_base,a6
  7730.         move.l    xfh_pointer,a0
  7731.         jsr    XpkClose(a6)
  7732.  
  7733.         move.l    dos_base,a6            ;open the data file.
  7734.         move.l    dir_n_name_ptr,d1        ;the name of the file.
  7735.         move.l    #MODE_OLDFILE,d2
  7736.         jsr    Open(a6)            ;narsk.
  7737.         move.l    d0,file_hd
  7738.         beq.w    quit_xpk_e            ;file error!
  7739.  
  7740.         lea    status_xpk_unpack_txt,a5
  7741.         bsr.w    print_status_middle
  7742.  
  7743.         move.l    xpk_master_base,a6
  7744.         lea    xpk_unp_tags,a0
  7745.         move.l    file_hd,4(a0)
  7746.         move.l    cartridge_data,12(a0)
  7747.         move.l    file_length,20(a0)        ;output area length!
  7748.         jsr    XpkUnpack(a6)
  7749.         tst.l    d0
  7750.         bne.s    xpk_argh            ;error here!
  7751.  
  7752.         move.l    dos_base,a6
  7753.         move.l    file_hd,d1
  7754.         jsr    Close(a6)            ;click.
  7755.  
  7756.         sub.l    #XPK_MARGIN,file_length        ;xpk margin area.
  7757.         bra.w    load_ok
  7758.  
  7759. xpk_argh:    move.l    dos_base,a6
  7760.         move.l    file_hd,d1
  7761.         jsr    Close(a6)            ;click.
  7762.  
  7763.         bra.w    load_error_xpk_error
  7764.  
  7765. quit_xpk_e:    move.l    xpk_master_base,a6        ;an error occurred!
  7766.         move.l    xfh_pointer,a0
  7767.         jsr    XpkClose(a6)
  7768.  
  7769.         bra.w    load_error_file_not_found
  7770.  
  7771. quit_xpk_e_mem:    move.l    xpk_master_base,a6        ;an error occurred!
  7772.         move.l    xfh_pointer,a0
  7773.         jsr    XpkClose(a6)
  7774.  
  7775.         bra.w    load_error_not_enough_memory
  7776.  
  7777. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7778. ;        memorize the dir
  7779. ;        INPUT:
  7780. ;        a0    = output.
  7781. ;        a2    = input.
  7782. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7783.  
  7784. memorize_dir:    moveq.l    #120-1,d1            ;max letters.
  7785.         tst.b    (a2)                ;current directory?
  7786.         beq.s    xexit_path            ;yes. skip this part.
  7787. xcopy_path:    move.b    (a2)+,d1
  7788.         beq.s    xexit_path            ;path is done.
  7789.         move.b    d1,(a0)+            ;output path.
  7790.         dbra    d1,xcopy_path            ;next letter.
  7791.  
  7792. xexit_path:    clr.b    (a0)                ;the end.
  7793.         rts
  7794.  
  7795. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7796. ;        normal dos open and loading
  7797. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7798.  
  7799. quit_xpk:    move.l    xpk_master_base,a6
  7800.         move.l    xfh_pointer,a0            ;it was not packed.
  7801.         jsr    XpkClose(a6)
  7802.  
  7803. no_xpk_open:    move.l    dos_base,a6
  7804.         move.l    dir_n_name_ptr,d1
  7805.         moveq.l    #ACCESS_READ,d2
  7806.         jsr    Lock(a6)
  7807.         move.l    d0,d7
  7808.         beq.w    load_error_file_not_found
  7809.  
  7810.         move.l    file_info_ptr,d2
  7811.         move.l    d0,d1
  7812.         jsr    Examine(a6)
  7813.  
  7814.         move.l    d7,d1
  7815.         jsr    UnLock(a6)
  7816.  
  7817.         move.l    file_info_ptr,a0
  7818.         move.l    fib_Size(a0),file_length
  7819.  
  7820. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7821. ;        allocate memory
  7822. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7823.  
  7824.         bsr.w    alloc_cart_mem            ;allocate memory for
  7825.                             ;the cartridge.
  7826.         tst.l    d7
  7827.         beq.w    load_error_not_enough_memory    ;not enough! quit.
  7828.  
  7829. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7830. ;        now load the file
  7831. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7832.  
  7833.         move.l    dos_base,a6
  7834.         move.l    dir_n_name_ptr,d1
  7835.         move.l    #MODE_OLDFILE,d2
  7836.         jsr    Open(a6)
  7837.         move.l    d0,d7
  7838.         beq.w    load_error_file_not_found
  7839.  
  7840.         move.l    d0,d1
  7841.         move.l    cartridge_data,d2
  7842.         move.l    file_length,d3
  7843.         jsr    Read(a6)
  7844.  
  7845.         move.l    d7,d1
  7846.         jsr    Close(a6)
  7847.  
  7848. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7849. ;        create the bank switching table
  7850. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7851.  
  7852. load_ok:    move.l    file_length,cartridge_data_length
  7853.         clr.b    load_or_reset
  7854.  
  7855. load_ok_ok:    move.l    cartridge_data_length,file_length
  7856.  
  7857. ;        move.l    gb_memory,a0
  7858. ;        move.l    a0,a1                ;output.
  7859. ;        move.w    #$10000/4/4-1,d0
  7860. ;        moveq.l    #0,d1
  7861. ;empty_ram:    move.l    d1,(a0)+
  7862. ;        move.l    d1,(a0)+
  7863. ;        move.l    d1,(a0)+
  7864. ;        move.l    d1,(a0)+
  7865. ;        dbra    d0,empty_ram
  7866.  
  7867. gg_patch_apply:    clr.b    rom_type
  7868.         move.l    cartridge_data,a0
  7869.  
  7870.         move.l    file_length,d7
  7871.         divu.w    #16384,d7
  7872.  
  7873.         move.l    d7,d0
  7874.         swap    d0
  7875.         tst.w    d0
  7876.         beq.s    rom_size_okay
  7877.  
  7878.         sub.w    #512,d0
  7879.         bne.w    load_error_unknown_size
  7880.  
  7881.         move.b    #1,rom_type
  7882.         add.l    #512,a0
  7883.  
  7884. rom_size_okay:    and.l    #$ffff,d7
  7885.         move.l    a0,cartridge
  7886.         move.l    a0,a1
  7887.         move.l    rom_32k,a2
  7888.  
  7889.         cmp.b    #$19,$147(a0)
  7890.         bne.s    rom_mbc_is_not_5
  7891.  
  7892.         move.w    #$4000/4-1,d1
  7893. rom_mbc5_32k_0:    move.l    (a1)+,(a2)+
  7894.         dbra    d1,rom_mbc5_32k_0
  7895.         move.l    a0,a1
  7896.         move.w    #$4000/4-1,d1
  7897. rom_mbc5_32k_1:    move.l    (a1)+,(a2)+
  7898.         dbra    d1,rom_mbc5_32k_1
  7899.  
  7900.         bra.s    rom_bank_0_done
  7901.  
  7902. rom_mbc_is_not_5:
  7903.         move.w    #$8000/4-1,d1
  7904. rom_32k_0:    move.l    (a1)+,(a2)+
  7905.         dbra    d1,rom_32k_0
  7906.  
  7907. rom_bank_0_done:subq.l    #2,d7
  7908.         beq.s    rom_32k_created
  7909.  
  7910.         sub.l    #$4000,a1
  7911.         addq.l    #1,d7
  7912.  
  7913. rom_32k_n_more:    move.w    #$4000/4-1,d1
  7914.         move.l    a0,a3
  7915. rom_32k_n_0:    move.l    (a3)+,(a2)+
  7916.         dbra    d1,rom_32k_n_0
  7917.  
  7918.         move.w    #$4000/4-1,d1
  7919. rom_32k_n:    move.l    (a1)+,(a2)+
  7920.         dbra    d1,rom_32k_n
  7921.  
  7922.         subq.l    #1,d7
  7923.         bne.s    rom_32k_n_more
  7924.  
  7925. rom_32k_created:move.l    rom_32k,bank_address        ;use area b0, b1.
  7926.         moveq.l    #0,d0                ;no errors.
  7927.         rts
  7928.  
  7929. load_error_not_selected:
  7930.         moveq.l    #1,d0                ;an error has occurred!
  7931.         rts
  7932.  
  7933. load_error_file_not_found:
  7934.         lea    status_file_not_found_txt,a5
  7935.         bsr.w    print_status_middle
  7936.         moveq.l    #2,d0                ;an error has occurred!
  7937.         rts
  7938.  
  7939. load_error_xpk_error:
  7940.         lea    status_xpk_error_txt,a5
  7941.         bsr.w    print_status_middle
  7942.         moveq.l    #2,d0                ;an error has occurred!
  7943.         rts
  7944.  
  7945. load_error_not_enough_memory:
  7946.         lea    status_not_enough_memory_txt,a5
  7947.         bsr.w    print_status_middle
  7948.         moveq.l    #2,d0                ;an error has occurred!
  7949.         rts
  7950.  
  7951. load_error_unknown_size:
  7952.         lea    status_unknown_rom_size_txt,a5
  7953.         bsr.w    print_status_middle
  7954.         moveq.l    #2,d0                ;an error has occurred!
  7955.         rts
  7956.  
  7957. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7958. ;        cartridge loader memory handler
  7959. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7960.  
  7961. alloc_cart_mem:    bsr.b    free_cart_mem
  7962.  
  7963.         move.l    exec_base,a6
  7964.         move.l    file_length,d0
  7965.         moveq.l    #MEMF_PUBLIC,d1            ;the system flags.
  7966.         jsr    AllocVec(a6)
  7967.         move.l    d0,cartridge_data        ;the pointer here.
  7968.         beq.s    alloc_cart_mem_error
  7969.  
  7970.         move.l    file_length,d0
  7971.         lsl.l    #1,d0
  7972.         moveq.l    #MEMF_PUBLIC,d1            ;the system flags.
  7973.         jsr    AllocVec(a6)
  7974.         move.l    d0,rom_32k            ;the pointer here.
  7975.         beq.s    alloc_cart_mem_error
  7976.  
  7977.         moveq.l    #1,d7
  7978.         rts
  7979.  
  7980. alloc_cart_mem_error:
  7981.         moveq.l    #0,d7
  7982.         rts
  7983.  
  7984. free_cart_mem:    move.l    exec_base,a6
  7985.         move.l    cartridge_data,d0
  7986.         beq.s    free_cart_mem_allocate_rom_32k    ;no cartridge loaded.
  7987.         move.l    d0,a1
  7988.         jsr    FreeVec(a6)            ;free the old area.
  7989.  
  7990. free_cart_mem_allocate_rom_32k:
  7991.         move.l    rom_32k,d0
  7992.         beq.s    free_cart_mem_exit
  7993.         move.l    d0,a1
  7994.         jsr    FreeVec(a6)            ;free the old area.
  7995.  
  7996. free_cart_mem_exit:
  7997.         rts
  7998.  
  7999. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8000. ;        get the xpk packer name that was used to pack the file
  8001. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8002.  
  8003. get_packer_name:move.l    xfh_pointer,a0
  8004.         move.l    xf_ID(a0),status_xpk_name_u_txt
  8005.         rts
  8006.  
  8007. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8008. ;        join the directory and name into a single expression
  8009. ;        INPUT:
  8010. ;        a2    = the requester pointer.
  8011. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8012.  
  8013. parse_req_name:    move.l    dir_n_name_ptr,a0        ;output.
  8014.         move.l    name_ptr,a1            ;name.
  8015.         move.l    rtfi_Dir(a2),a2
  8016.  
  8017.         moveq.l    #120,d0                ;max letters.
  8018.         tst.b    (a2)                ;current directory?
  8019.         beq.s    no_path_fix            ;yes. skip this part.
  8020. copy_path:    move.b    (a2)+,d1
  8021.         beq.s    exit_path            ;path is done.
  8022.         move.b    d1,(a0)+            ;output path.
  8023.         dbra    d0,copy_path            ;next letter.
  8024. ;        bra.s    exit_path            ;too many letters! quit!
  8025.  
  8026. exit_path:    cmp.b    #':',-1(a0)            ;device?
  8027.         beq.s    no_path_fix            ;yes. no need to fix the output.
  8028.         move.b    #'/',(a0)+            ;fixed the directory name.
  8029.  
  8030. no_path_fix:    moveq.l    #120,d0                ;max letters.
  8031. copy_name:    move.b    (a1)+,d1
  8032.         beq.s    exit_name            ;name is done.
  8033.         move.b    d1,(a0)+            ;output name.
  8034.         dbra    d0,copy_name            ;next letter.
  8035. ;        bra.s    exit_name            ;too many letters! quit!
  8036.  
  8037. exit_name:    clr.b    (a0)                ;end of file name.
  8038.         rts
  8039.  
  8040. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8041. ;        compute a jump list for gameboy memory management
  8042. ;        INPUT:
  8043. ;        a0    = pointer to a cartridge (0 = n/a).
  8044. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8045.  
  8046. compute_jmp_lst:move.l    a0,d0
  8047.         beq.w    no_jmp_list
  8048.  
  8049.         lea    mapper_list,a2
  8050.         moveq.l    #0,d0
  8051.  
  8052.         move.b    $147(a0),d0            ;d0 = cartridge type.
  8053.         cmp.b    #$ff,d0
  8054.         bne.s    no_huc1
  8055.  
  8056.         move.l    #mapper_huc1_ram_battery,a2
  8057.         bra.s    mapper_ok_n
  8058.  
  8059. no_huc1:    move.l    (a2,d0.l*4),a2            ;mapper selected.
  8060.  
  8061. mapper_ok_n:    move.b    $149(a0),d0            ;d0 = amount of ram.
  8062.         and.b    #%11,d0                ;max values.
  8063.         move.l    (a2,d0.l*4),a2            ;list selected.
  8064.  
  8065. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8066. ;        INPUT:
  8067. ;        a2    = cartridge memory structure
  8068. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8069.  
  8070.         move.l    gb_mem_jumps,a1            ;a1 = output table.
  8071.         move.l    #gb_mem_wr,d0
  8072.         move.l    #$10000,d1
  8073. gb_mem_init:    move.l    d0,(a1)+
  8074.         subq.l    #1,d1
  8075.         bne.s    gb_mem_init
  8076.  
  8077.         move.l    gb_mem_jumps,a1
  8078.         move.l    (a2)+,d0            ;dbra amount of sections.
  8079.         move.l    (a2)+,d1            ;dbra size of a section.
  8080. create_banking:    move.l    d1,d2
  8081.         move.l    (a2)+,d3
  8082.  
  8083. create_banking_move_data:
  8084.         move.l    d3,(a1)+
  8085.         dbra    d2,create_banking_move_data
  8086.         dbra    d0,create_banking
  8087.  
  8088.         move.l    gb_mem_jumps,a1
  8089.         add.l    #$c000*4,a1
  8090.         move.w    #$de00-$c000-1,d0
  8091.         move.l    #echo_up,d1
  8092. gb_mem_up:    move.l    d1,(a1)+
  8093.         dbra    d0,gb_mem_up
  8094.  
  8095.         move.l    gb_mem_jumps,a1
  8096.         add.l    #$e000*4,a1
  8097.         move.w    #$fe00-$e000-1,d0
  8098.         move.l    #echo_down,d1
  8099. gb_mem_down:    move.l    d1,(a1)+
  8100.         dbra    d0,gb_mem_down
  8101.  
  8102.         move.l    gb_mem_jumps,a1
  8103.         add.l    #$ff00*4,a1
  8104.         lea    ffxx_jmp_table,a2
  8105.         move.w    #$100-1,d0
  8106. gb_mem_ffxx:    move.l    (a2)+,(a1)+
  8107.         dbra    d0,gb_mem_ffxx
  8108.  
  8109.         move.l    gb_mem_jumps,a1
  8110.         add.l    #$fea0*4,a1
  8111.         move.l    #no_write,d1
  8112.         move.w    #$ff00-$fea0-1,d0
  8113. gb_mem_no_write:move.l    d1,(a1)+
  8114.         dbra    d0,gb_mem_no_write
  8115.  
  8116.         move.l    exec_base,a6
  8117.         jsr    CacheClearU(a6)            ;clear the caches.
  8118.  
  8119. no_jmp_list:    rts
  8120.  
  8121. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8122. ;        decode a gamegenie patch
  8123. ;        OUTPUT:
  8124. ;        d0    = new value.B.
  8125. ;        d1    = address.W.
  8126. ;        d2    = compare value.B.
  8127. ;        d6    = state (0 = no errors / 1 = error).
  8128. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8129.  
  8130. decode_gg_patch:lea    gg_patch,a1
  8131.  
  8132.         move.b    (a1),d7
  8133.         bsr.w    convert_ascii_to_hex
  8134.         tst.l    d6
  8135.         bne.w    decode_gg_patch_error
  8136.         move.b    d7,d0
  8137.         lsl.b    #4,d0
  8138.         move.b    1(a1),d7
  8139.         bsr.w    convert_ascii_to_hex
  8140.         tst.l    d6
  8141.         bne.w    decode_gg_patch_error
  8142.         or.b    d7,d0                ;d0 = new value.B.
  8143.  
  8144.         moveq.l    #$f,d1
  8145.         move.b    5(a1),d7
  8146.         bsr.w    convert_ascii_to_hex
  8147.         tst.l    d6
  8148.         bne.w    decode_gg_patch_error
  8149.         btst    #3,d7
  8150.         bne.s    decode_gg_patch_address_ok
  8151.  
  8152.         moveq.l    #1,d6                ;error in decoding!
  8153.         rts
  8154.  
  8155. decode_gg_patch_address_ok:
  8156.         sub.b    d7,d1
  8157.         lsl.b    #4,d1
  8158.         move.b    2(a1),d7
  8159.         bsr.b    convert_ascii_to_hex
  8160.         tst.l    d6
  8161.         bne.w    decode_gg_patch_error
  8162.         or.b    d7,d1
  8163.         lsl.w    #4,d1
  8164.         move.b    3(a1),d7
  8165.         bsr.b    convert_ascii_to_hex
  8166.         tst.l    d6
  8167.         bne.w    decode_gg_patch_error
  8168.         or.b    d7,d1
  8169.         lsl.w    #4,d1
  8170.         move.b    4(a1),d7
  8171.         bsr.b    convert_ascii_to_hex
  8172.         tst.l    d6
  8173.         bne.w    decode_gg_patch_error
  8174.         or.b    d7,d1                ;d1 = address.W.
  8175.  
  8176.         move.b    6(a1),d7
  8177.         bsr.b    convert_ascii_to_hex
  8178.         tst.l    d6
  8179.         bne.s    decode_gg_patch_error
  8180.         move.b    d7,d2
  8181.         lsl.b    #4,d2
  8182.         move.b    8(a1),d7
  8183.         bsr.b    convert_ascii_to_hex
  8184.         tst.l    d6
  8185.         bne.s    decode_gg_patch_error
  8186.         or.b    d7,d2                ;d2 = compare value.B.
  8187.  
  8188.         eor.b    #$ff,d2
  8189.         ror.b    #2,d2
  8190.         eor.b    #$45,d2
  8191.  
  8192.         move.b    6(a1),d7
  8193.         bsr.b    convert_ascii_to_hex
  8194.         tst.l    d6
  8195.         bne.s    decode_gg_patch_error
  8196.         move.b    d7,d3
  8197.         move.b    7(a1),d7
  8198.         bsr.b    convert_ascii_to_hex
  8199.         tst.l    d6
  8200.         bne.s    decode_gg_patch_error
  8201.         eor.b    d7,d3
  8202.         tst.l    d3
  8203.         beq.s    decode_gg_patch_all_ok
  8204.         and.b    #%11111000,d3
  8205.         bne.s    decode_gg_patch_all_ok
  8206.  
  8207. decode_gg_patch_error:
  8208.         moveq.l    #1,d6                ;error in decoding!
  8209.         rts
  8210.  
  8211. decode_gg_patch_all_ok:
  8212.         moveq.l    #0,d6                ;no errors!
  8213.         rts
  8214.  
  8215. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8216. ;        convert ascii to hex
  8217. ;        INPUT:
  8218. ;        d7    = ascii.B.
  8219. ;        OUTPUT:
  8220. ;        d7    = hex.B.
  8221. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8222.  
  8223. convert_ascii_to_hex:
  8224.         moveq.l    #0,d6
  8225.         and.l    #$ff,d7
  8226.         cmp.w    #"0",d7
  8227.         blt.s    convert_ascii_to_hex_no_number
  8228.         cmp.w    #"9",d7
  8229.         bgt.s    convert_ascii_to_hex_no_number
  8230.         sub.b    #"0",d7
  8231.         rts
  8232.  
  8233. convert_ascii_to_hex_no_number:
  8234.         cmp.w    #"A",d7
  8235.         blt.s    convert_ascii_to_hex_no_upper_case
  8236.         cmp.w    #"F",d7
  8237.         bgt.s    convert_ascii_to_hex_no_upper_case
  8238.         sub.b    #"A",d7
  8239.         add.b    #$a,d7
  8240.         rts
  8241.  
  8242. convert_ascii_to_hex_no_upper_case:
  8243.         cmp.w    #"a",d7
  8244.         blt.s    convert_ascii_to_hex_error
  8245.         cmp.w    #"f",d7
  8246.         bgt.s    convert_ascii_to_hex_error
  8247.         sub.b    #"a",d7
  8248.         add.b    #$a,d7
  8249.         rts
  8250.  
  8251. convert_ascii_to_hex_error:
  8252.         moveq.l    #1,d6                ;error in decoding!
  8253.         rts
  8254.  
  8255. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8256. ;        the gameboy emulation routine. only fresh ROM and fresh
  8257. ;        ROM with battery come here, GBS loading skips this part.
  8258. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8259.  
  8260. run_cartridge:
  8261.  
  8262. use_loaded_battery_ram_x:
  8263.         move.l    memory_banks,a0
  8264.         move.l    gb_memory,a1
  8265.         add.l    #$A000,a1
  8266.         move.w    #$2000/4-1,d0
  8267. copy_ram_banks_x:
  8268.         move.l    (a0)+,(a1)+
  8269.         dbra    d0,copy_ram_banks_x
  8270.  
  8271. ram_banks_done:    move.l    cartridge,a1            ;a0 = $c000.
  8272.         add.l    #$100,a1
  8273.         move.w    #$2000/4-1,d0
  8274. randomize_ram_1:move.l    (a1)+,(a0)+
  8275.         dbra    d0,randomize_ram_1
  8276.  
  8277.         move.w    #($fe00-$e000)/4-1,d0        ;a0 = $e000.
  8278. randomize_ram_2:move.l    (a1)+,(a0)+
  8279.         dbra    d0,randomize_ram_2
  8280.  
  8281.         move.l    gb_memory,a0
  8282.         add.l    #$ff4c,a0
  8283.         moveq.l    #$34-1,d0
  8284. clear_misc_registers:
  8285.         clr.b    (a0)+
  8286.         dbra    d0,clear_misc_registers
  8287.  
  8288. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8289. ;        move on with the inits
  8290. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8291.  
  8292.         bsr.w    gb_memory_at_start
  8293.  
  8294.         move.b    #$cf,buttons_byte
  8295.         move.b    #$cf,directions_byte
  8296.         move.b    #$cf,buttons_byte_o
  8297.         move.b    #$cf,directions_byte_o
  8298.  
  8299.         clr.b    transfer_counter
  8300.  
  8301.         move.b    #1,i_flag            ;disable interrupts.
  8302.         clr.b    z80_halt            ;CPU is not halted.
  8303.  
  8304.         move.l    exec_base,a6
  8305.         jsr    CacheClearU(a6)            ;any help?
  8306.  
  8307.         bsr.w    z80_start            ;do the inits.
  8308.         bsr.w    push_z80            ;push all the registers.
  8309.  
  8310. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8311. ;        the gameboy loop
  8312. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8313.  
  8314. cartridge_loop:    
  8315.         IFGT    GAMEBOY_DEBUG
  8316.         clr.b    debug_exit
  8317.         ENDIF
  8318.  
  8319.         move.l    #h_values,h_values_indexed
  8320.         bsr.w    pull_z80            ;pull all the registers.
  8321.  
  8322.         move.l    a2,a6
  8323.         add.l    #$ff00,a6
  8324.         clr.l    gb_scanlines            ;start from scanline zero.
  8325.         clr.b    $44(a6)                ;scanline zero.
  8326.  
  8327. next_sline:
  8328.         IFGT    GAMEBOY_DEBUG
  8329.         bsr.w    debug_scanline_out
  8330.         ENDIF
  8331.  
  8332.         IFLE    Z80_MODE
  8333.  
  8334.         cmp.l    #1,gb_scanlines
  8335.         bne.s    cmp_blank
  8336.         bclr.b    #1,irq_status_flags        ;past $00, no vbr effect.
  8337.  
  8338. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8339. ;        execute a line comparison irq if enabled
  8340. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8341.  
  8342. cmp_blank:    btst.b    #7,$40(a6)            ;lcd enabled?
  8343.         beq.s    cmp_up                ;no.
  8344.  
  8345.         btst.b    #1,irq_status_flags        ;vbr effect?
  8346.         beq.s    cmp_blank_no_filtering
  8347.  
  8348. ;        move.l    gb_scanlines,d7
  8349. ;;        beq.s    cmp_up                ;$00 is off limits.
  8350. ;        cmp.l    #$91,d7
  8351.                 cmp.l   #$91,gb_scanlines
  8352.         bge.s    cmp_up                ;$91-$99 are off limits, too.
  8353.  
  8354. cmp_blank_no_filtering:
  8355.         move.b    $45(a6),d7            ;d7 = ly compare / lyc.
  8356.         cmp.b    $44(a6),d7
  8357.         bne.s    lyc_clear            ;not the same.
  8358.         bset.b    #2,$41(a6)            ;coincidence occurred.
  8359.  
  8360.         btst.b    #6,$41(a6)            ;interrupt?
  8361.         beq.s    cmp_up                ;nope. disabled.
  8362.  
  8363.         btst.b    #1,$ff(a6)            ;lcd controller irq enabled?
  8364.         beq.s    cmp_up                ;no.
  8365.  
  8366. cmp_starts:
  8367.         IFGT    GAMEBOY_DEBUG
  8368.         bsr.w    debug_blank
  8369.         ENDIF
  8370.  
  8371.         bset.b    #1,$0f(a6)            ;lcd occurred.
  8372.         bset.b    #2,irq_status_flags        ;lyc occurred.
  8373.         bra.s    cmp_up                ;skip vbr.
  8374.  
  8375. lyc_clear:    bclr.b    #2,$41(a6)            ;no coincidence.
  8376. cmp_up:
  8377.  
  8378.         ENDIF
  8379.  
  8380. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8381. ;        0/4
  8382. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8383.  
  8384.         move.l    gb_scanlines,d7
  8385.         cmp.b    #40,d7
  8386.         beq.s    input_time
  8387.         cmp.b    #80,d7
  8388.         beq.s    input_time
  8389.         IFLE    Z80_MODE
  8390.         cmp.b    #120,d7
  8391.         beq.s    input_time
  8392.         ENDIF
  8393.         bra.s    no_input_this_time
  8394.  
  8395. input_time:    movem.l    d0-d6/a0-a6,-(SP)
  8396.         bsr.w    inputs_read            ;do the joystick input.
  8397.         movem.l    (SP)+,d0-d6/a0-a6
  8398.         bsr.w    input_irq
  8399.  
  8400. no_input_this_time:
  8401.         IFLE    Z80_MODE
  8402.         move.b    $07(a6),d7            ;d7 = timer control byte.
  8403.         btst    #2,d7                ;0 = stopped / 1 = counting.
  8404.         beq.s    no_timer_update_0        ;0! no update.
  8405.         bsr.w    irq_timer
  8406. no_timer_update_0:
  8407.         ENDIF
  8408.  
  8409.         and.b    #%11111100,$41(a6)
  8410.  
  8411.         move.l    h_values_indexed,a5
  8412.         move.b    (a5),d6
  8413.         or.b    d6,$41(a6)
  8414.  
  8415.         IFLE    Z80_MODE
  8416.  
  8417.         cmp.l    #143,gb_scanlines
  8418.         bne.s    no_vbr_lcd
  8419.         btst.b    #2,irq_status_flags        ;lyc occurred?
  8420.         bne.s    no_lcd_irq_emulation_0        ;mask vbr lcd irq out.
  8421.  
  8422. no_vbr_lcd:    cmp.l    #144,gb_scanlines
  8423.         bgt.s    no_lcd_irq_emulation_0
  8424. ;        tst.b    i_flag
  8425. ;        bne.s    no_lcd_irq_emulation_0
  8426. ;        btst.b    #1,$ff(a6)            ;lcd controller irq?
  8427. ;        beq.s    no_lcd_irq_emulation_0        ;no. quit.
  8428.  
  8429.         bsr.w    lcd_irq_eh
  8430.  
  8431. no_lcd_irq_emulation_0:
  8432.         ENDIF
  8433.  
  8434.         cmp.l    #144,gb_scanlines
  8435.         bne.s    no_vbr_blank            ;no vbr interrupt.
  8436.  
  8437. vbr_blank:    btst.b    #7,$40(a6)            ;lcd operation?
  8438.         beq.s    no_vbr_blank            ;no. quit.
  8439.  
  8440.         btst.b    #0,$ff(a6)            ;vbr irq?
  8441.         beq.s    no_vbr_blank            ;no. quit.
  8442.  
  8443.         bset.b    #1,irq_status_flags
  8444.         bset.b    #0,$0f(a6)            ;vbr occurred.
  8445.  
  8446.         IFGT    GAMEBOY_DEBUG
  8447.         bsr.w    debug_vbr
  8448.         ENDIF
  8449.  
  8450. no_vbr_blank:    move.b    $0f(a6),d7
  8451.         addq.l    #1,h_values_indexed
  8452.         and.b    #%11111,d7
  8453.         beq.s    no_interrupts_0
  8454.  
  8455.         tst.b    i_flag
  8456.         bne.s    no_interrupts_0
  8457.  
  8458. dehalting_z80_0:move.l    a0,d6                ;stack the pc.
  8459.         sub.l    z80_pc_base,d6
  8460.         clr.b    z80_halt
  8461.  
  8462.         btst    #0,d7
  8463.         bne.w    prior_i_0
  8464.  
  8465.         IFLE    Z80_MODE
  8466.         btst    #1,d7
  8467.         bne.w    prior_ii_0
  8468.         btst    #2,d7
  8469.         bne.w    prior_iii_0
  8470.         ENDIF
  8471.  
  8472.         btst    #3,d7
  8473.         bne.w    prior_iv_0
  8474.  
  8475.         bra.w    prior_v_0
  8476.  
  8477. no_interrupts_0:tst.b    z80_halt
  8478.         bne.w    cpu_halt_is_on_0
  8479.  
  8480.         bsr.w    z80_cpu_next_sweep
  8481.  
  8482. ei_loop_0:    tst.b    z80_ei_return
  8483.         beq.s    no_ei_return_0
  8484.         clr.b    z80_ei_return
  8485.         move.l    z80_cycles_left,a5
  8486.         bsr.l    reti_back
  8487.         bra.s    ei_loop_0
  8488.  
  8489. no_ei_return_0:
  8490.         IFGT    GAMEBOY_DEBUG
  8491.         tst.b    debug_exit
  8492.         bne.w    z80_halted
  8493.         ENDIF
  8494.  
  8495. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8496. ;        1/4
  8497. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8498.  
  8499. cpu_halt_is_on_0:
  8500.         move.l    a2,a6
  8501.         add.l    #$ff00,a6
  8502.  
  8503.         IFLE    Z80_MODE
  8504.         move.b    $07(a6),d7            ;d7 = timer control byte.
  8505.         btst    #2,d7                ;0 = stopped / 1 = counting.
  8506.         beq.w    no_timer_update_1        ;0! no update.
  8507.         bsr.w    irq_timer
  8508. no_timer_update_1:
  8509.         ENDIF
  8510.  
  8511.         cmp.l    #$99,gb_scanlines
  8512.         bne.s    no_ly_fix
  8513.         clr.b    $44(a6)                ;scanline zero (short last ly).
  8514.  
  8515. no_ly_fix:    subq.b    #1,transfer_counter
  8516.         bhi.w    no_transfer
  8517.         blt.w    no_transfer_reset
  8518.  
  8519.         bclr.b    #7,$2(a6)
  8520.  
  8521.         btst.b    #3,$ff(a6)
  8522.         beq.w    no_transfer
  8523.  
  8524.         bset.b    #3,$f(a6)
  8525.         move.b    #$ff,$1(a6)
  8526.  
  8527.         IFGT    GAMEBOY_SERIAL
  8528.  
  8529.         movem.l    d0-d7/a0-a6,-(SP)
  8530.  
  8531.         move.l    a6,a5
  8532.         move.l    io_buffer_out,a0
  8533.         move.b    $1(a5),(a0)
  8534.  
  8535.         move.l    exec_base,a6
  8536.         move.l    io_request_out,a1
  8537.         move.l    #1,IO_LENGTH(a1)
  8538.         move.l    io_buffer_out,IO_DATA(a1)
  8539.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  8540.         jsr    DoIO(a6)
  8541.         tst.l    d0
  8542.         bne.s    quit_gb_io
  8543.  
  8544.         move.l    io_request_in,a1
  8545.         move.l    #1,IO_LENGTH(a1)
  8546.         move.l    io_buffer_in,IO_DATA(a1)
  8547.         move.w    #CMD_READ,IO_COMMAND(a1)
  8548.         jsr    DoIO(a6)
  8549.         tst.l    d0
  8550.         bne.s    quit_gb_io
  8551.  
  8552.         move.l    io_request_in,a1
  8553.         jsr    WaitIO(a6)
  8554.  
  8555. quit_gb_io:    move.l    io_buffer_in,a0
  8556.         move.b    (a0),$1(a5)
  8557.  
  8558.         movem.l    (SP)+,d0-d7/a0-a6
  8559.  
  8560.         ENDIF
  8561.  
  8562. no_transfer_reset:
  8563.         clr.b    transfer_counter
  8564.  
  8565. no_transfer:    add.b    #1,$04(a6)            ;DIVIDER register.
  8566.         and.b    #%11111100,$41(a6)
  8567.  
  8568.         move.l    h_values_indexed,a5
  8569.         move.b    (a5),d6
  8570.         or.b    d6,$41(a6)
  8571.  
  8572.         IFLE    Z80_MODE
  8573.         cmp.l    #144,gb_scanlines
  8574.         bge.s    no_lcd_irq_emulation_1
  8575. ;        tst.b    i_flag
  8576. ;        bne.s    no_lcd_irq_emulation_1
  8577. ;        btst.b    #1,$ff(a6)            ;lcd controller irq?
  8578. ;        beq.s    no_lcd_irq_emulation_1        ;no. quit.
  8579.  
  8580.         bsr.w    lcd_irq_eh
  8581.  
  8582. no_lcd_irq_emulation_1:
  8583.         ENDIF
  8584.  
  8585.         move.b    $0f(a6),d7
  8586.         addq.l    #1,h_values_indexed
  8587.         and.b    #%11111,d7
  8588.         beq.s    no_interrupts_1
  8589.  
  8590.         tst.b    i_flag
  8591.         bne.s    no_interrupts_1
  8592.  
  8593. dehalting_z80_1:move.l    a0,d6                ;stack the pc.
  8594.         sub.l    z80_pc_base,d6
  8595.         clr.b    z80_halt
  8596.  
  8597.         btst    #0,d7
  8598.         bne.w    prior_i_1
  8599.  
  8600.         IFLE    Z80_MODE
  8601.         btst    #1,d7
  8602.         bne.w    prior_ii_1
  8603.         btst    #2,d7
  8604.         bne.w    prior_iii_1
  8605.         ENDIF
  8606.  
  8607.         btst    #3,d7
  8608.         bne.w    prior_iv_1
  8609.  
  8610.         bra.w    prior_v_1
  8611.  
  8612. no_interrupts_1:tst.b    z80_halt
  8613.         bne.w    cpu_halt_is_on_1
  8614.  
  8615.         bsr.w    z80_cpu_next_sweep
  8616.  
  8617. ei_loop_1:    tst.b    z80_ei_return
  8618.         beq.s    no_ei_return_1
  8619.         clr.b    z80_ei_return
  8620.         move.l    z80_cycles_left,a5
  8621.         bsr.l    reti_back
  8622.         bra.s    ei_loop_1
  8623.  
  8624. no_ei_return_1:
  8625.         IFGT    GAMEBOY_DEBUG
  8626.         tst.b    debug_exit
  8627.         bne.w    z80_halted
  8628.         ENDIF
  8629.  
  8630. cpu_halt_is_on_1:
  8631.  
  8632. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8633. ;        2/4
  8634. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8635.  
  8636.         move.l    a2,a6
  8637.         add.l    #$ff00,a6
  8638.  
  8639.         IFLE    Z80_MODE
  8640.         move.b    $07(a6),d7            ;d7 = timer control byte.
  8641.         btst    #2,d7                ;0 = stopped / 1 = counting.
  8642.         beq.w    no_timer_update_2        ;0! no update.
  8643.         bsr.w    irq_timer
  8644. no_timer_update_2:
  8645.         ENDIF
  8646.  
  8647.         and.b    #%11111100,$41(a6)
  8648.         move.l    h_values_indexed,a5
  8649.         move.b    (a5),d6
  8650.         or.b    d6,$41(a6)
  8651.  
  8652.         move.b    $0f(a6),d7
  8653.         addq.l    #1,h_values_indexed
  8654.         and.b    #%11111,d7
  8655.         beq.s    no_interrupts_2
  8656.  
  8657.         tst.b    i_flag
  8658.         bne.s    no_interrupts_2
  8659.  
  8660. dehalting_z80_2:move.l    a0,d6                ;stack the pc.
  8661.         sub.l    z80_pc_base,d6
  8662.         clr.b    z80_halt
  8663.  
  8664.         btst    #0,d7
  8665.         bne.w    prior_i_2
  8666.  
  8667.         IFLE    Z80_MODE
  8668.         btst    #1,d7
  8669.         bne.w    prior_ii_2
  8670.         btst    #2,d7
  8671.         bne.w    prior_iii_2
  8672.         ENDIF
  8673.  
  8674.         btst    #3,d7
  8675.         bne.w    prior_iv_2
  8676.  
  8677.         bra.w    prior_v_2
  8678.  
  8679. no_interrupts_2:tst.b    z80_halt
  8680.         bne.w    cpu_halt_is_on_2
  8681.  
  8682.         bsr.w    z80_cpu_next_sweep
  8683.  
  8684. ei_loop_2:    tst.b    z80_ei_return
  8685.         beq.s    no_ei_return_2
  8686.         clr.b    z80_ei_return
  8687.         move.l    z80_cycles_left,a5
  8688.         bsr.l    reti_back
  8689.         bra.s    ei_loop_2
  8690.  
  8691. no_ei_return_2:
  8692.         IFGT    GAMEBOY_DEBUG
  8693.         tst.b    debug_exit
  8694.         bne.w    z80_halted
  8695.         ENDIF
  8696.  
  8697. cpu_halt_is_on_2:
  8698.  
  8699.         tst.b    old_refresh            ;144/144 mode?
  8700.         bne.s    no_144_144_2            ;no.
  8701.         bsr.w    scanline_draw            ;yes. draw a scanline.
  8702.         bra.s    xan_drawed_2
  8703.  
  8704. no_144_144_2:    move.l    gb_scanlines,d7
  8705.         cmp.b    refresh_scanline,d7
  8706.         bne.s    xan_drawed_2
  8707.  
  8708.         move.b    output_bit,d7
  8709.         cmp.b    frame_update,d7
  8710.         bne.s    xan_drawed_2
  8711.  
  8712.         bsr.w    screen_draw            ;update the gameboy's screen.
  8713.  
  8714. xan_drawed_2:
  8715.  
  8716. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8717. ;        3/4
  8718. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8719.  
  8720.         move.l    a2,a6
  8721.         add.l    #$ff00,a6
  8722.  
  8723.         IFLE    Z80_MODE
  8724.         move.b    $07(a6),d7            ;d7 = timer control byte.
  8725.         btst    #2,d7                ;0 = stopped / 1 = counting.
  8726.         beq.w    no_timer_update_3        ;0! no update.
  8727.         bsr.w    irq_timer
  8728. no_timer_update_3:
  8729.         ENDIF
  8730.  
  8731.         addq.b    #1,$04(a6)            ;DIVIDER register.
  8732.         and.b    #%11111100,$41(a6)
  8733.  
  8734.         move.l    h_values_indexed,a5
  8735.         move.b    (a5),d6
  8736.         or.b    d6,$41(a6)
  8737.  
  8738.         IFLE    Z80_MODE
  8739.         cmp.l    #144,gb_scanlines
  8740.         bge.s    no_lcd_irq_emulation_3
  8741. ;        tst.b    i_flag
  8742. ;        bne.s    no_lcd_irq_emulation_3
  8743. ;        btst.b    #1,$ff(a6)            ;lcd controller irq?
  8744. ;        beq.s    no_lcd_irq_emulation_3        ;no. quit.
  8745.  
  8746.         bsr.w    lcd_irq_eh
  8747.  
  8748. no_lcd_irq_emulation_3:
  8749.         ENDIF
  8750.  
  8751.         move.b    $0f(a6),d7
  8752.         addq.l    #1,h_values_indexed
  8753.         and.b    #%11111,d7
  8754.         beq.s    no_interrupts_3
  8755.  
  8756.         tst.b    i_flag
  8757.         bne.s    no_interrupts_3
  8758.  
  8759. dehalting_z80_3:move.l    a0,d6                ;stack the pc.
  8760.         sub.l    z80_pc_base,d6
  8761.         clr.b    z80_halt
  8762.  
  8763.         btst    #0,d7
  8764.         bne.w    prior_i_3
  8765.  
  8766.         IFLE    Z80_MODE
  8767.         btst    #1,d7
  8768.         bne.w    prior_ii_3
  8769.         btst    #2,d7
  8770.         bne.w    prior_iii_3
  8771.         ENDIF
  8772.  
  8773.         btst    #3,d7
  8774.         bne.w    prior_iv_3
  8775.  
  8776.         bra.w    prior_v_3
  8777.  
  8778. no_interrupts_3:tst.b    z80_halt
  8779.         bne.w    cpu_halt_is_on_3
  8780.  
  8781.         bsr.w    z80_cpu_next_sweep
  8782.  
  8783. ei_loop_3:    tst.b    z80_ei_return
  8784.         beq.s    no_ei_return_3
  8785.         clr.b    z80_ei_return
  8786.         move.l    z80_cycles_left,a5
  8787.         bsr.l    reti_back
  8788.         bra.s    ei_loop_3
  8789.  
  8790. no_ei_return_3:
  8791.         IFGT    GAMEBOY_DEBUG
  8792.         tst.b    debug_exit
  8793.         bne.w    z80_halted
  8794.         ENDIF
  8795.  
  8796. cpu_halt_is_on_3:
  8797.  
  8798. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8799. ;        4/4
  8800. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8801.  
  8802.         move.l    a2,a6
  8803.         add.l    #$ff00,a6
  8804.  
  8805.         IFLE    Z80_MODE
  8806.         move.b    $07(a6),d7            ;d7 = timer control byte.
  8807.         btst    #2,d7                ;0 = stopped / 1 = counting.
  8808.         beq.w    no_timer_update_4        ;0! no update.
  8809.         bsr.w    irq_timer
  8810. no_timer_update_4:
  8811.         ENDIF
  8812.  
  8813.         and.b    #%11111100,$41(a6)
  8814.  
  8815.         move.l    h_values_indexed,a5
  8816.         move.b    (a5),d6
  8817.         or.b    d6,$41(a6)
  8818.  
  8819.         move.b    $0f(a6),d7
  8820.         addq.l    #1,h_values_indexed
  8821.         and.b    #%11111,d7
  8822.         beq.s    no_interrupts_4
  8823.  
  8824.         tst.b    i_flag
  8825.         bne.s    no_interrupts_4
  8826.  
  8827. dehalting_z80_4:move.l    a0,d6                ;stack the pc.
  8828.         sub.l    z80_pc_base,d6
  8829.         clr.b    z80_halt
  8830.  
  8831.         btst    #0,d7
  8832.         bne.w    prior_i_4
  8833.  
  8834.         IFLE    Z80_MODE
  8835.         btst    #1,d7
  8836.         bne.w    prior_ii_4
  8837.         btst    #2,d7
  8838.         bne.w    prior_iii_4
  8839.         ENDIF
  8840.  
  8841.         btst    #3,d7
  8842.         bne.w    prior_iv_4
  8843.  
  8844.         bra.w    prior_v_4
  8845.  
  8846. no_interrupts_4:tst.b    z80_halt
  8847.         bne.w    cpu_halt_is_on_4
  8848.  
  8849.         bsr.w    z80_cpu_next_sweep
  8850.  
  8851. ei_loop_4:    tst.b    z80_ei_return
  8852.         beq.s    no_ei_return_4
  8853.         clr.b    z80_ei_return
  8854.         move.l    z80_cycles_left,a5
  8855.         bsr.l    reti_back
  8856.         bra.s    ei_loop_4
  8857.  
  8858. no_ei_return_4:
  8859.         IFGT    GAMEBOY_DEBUG
  8860.         tst.b    debug_exit
  8861.         bne.w    z80_halted
  8862.         ENDIF
  8863.  
  8864. cpu_halt_is_on_4:
  8865.  
  8866. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8867. ;        do envelope sweeps if selected
  8868. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8869.  
  8870.         tst.b    snd_quality
  8871.         beq.s    snd_high_do
  8872.  
  8873. snd_high_back:    cmp.l    #153,gb_scanlines        ;end of lines?
  8874.         beq.w    next_frame            ;next frame.
  8875.  
  8876.         addq.l    #1,gb_scanlines            ;next scanline.
  8877.  
  8878. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8879. ;        next scanline, update registers
  8880. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8881.  
  8882. next_scanline:    move.l    a2,a6
  8883.         move.l    gb_scanlines,d7
  8884.         add.l    #$ff00,a6
  8885.  
  8886.         and.b    #%10,irq_status_flags        ;clear oam and lyc flag.
  8887.         move.b    d7,$44(a6)            ;next scanline (address).
  8888.         bra.w    next_sline            ;next horizontal line.
  8889.  
  8890. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8891. ;        input
  8892. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8893.  
  8894. input_irq:    move.b    (a6),d6
  8895.         btst    #5,d6
  8896.         beq.s    key_irq_buttons
  8897.         btst    #4,d6
  8898.         beq.s    key_irq_cross
  8899.         bra.s    input_irq_exit
  8900.  
  8901. key_irq_cross:    lea    directions_byte_o,a5
  8902.         move.b    directions_byte,d7
  8903.         cmp.b    (a5),d7
  8904.         beq.s    input_irq_exit
  8905.  
  8906.         btst.b    #4,$ff(a6)            ;keypad irq?
  8907.         beq.s    input_irq_exit            ;no. quit.
  8908.  
  8909.         bset.b    #4,$0f(a6)            ;transition occurred.
  8910.         move.b    d7,(a5)
  8911.  
  8912.         IFGT    GAMEBOY_DEBUG
  8913.         bsr.w    debug_p10
  8914.         ENDIF
  8915.  
  8916.         bra.s    input_irq_exit
  8917.  
  8918. key_irq_buttons:lea    buttons_byte_o,a5
  8919.         move.b    buttons_byte,d7
  8920.         cmp.b    (a5),d7
  8921.         beq.s    input_irq_exit
  8922.  
  8923.         btst.b    #4,$ff(a6)            ;keypad irq?
  8924.         beq.s    input_irq_exit            ;no. quit.
  8925.  
  8926.         bset.b    #4,$0f(a6)            ;transition occurred.
  8927.         move.b    d7,(a5)
  8928.  
  8929.         IFGT    GAMEBOY_DEBUG
  8930.         bsr.w    debug_p10
  8931.         ENDIF
  8932.  
  8933. input_irq_exit:    rts
  8934.  
  8935. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8936. ;        do audio sweeps
  8937. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8938.  
  8939. snd_high_do:
  8940.  
  8941.         tst.b    snd_chnlI
  8942.         bne.w    snd_high_no_I_f
  8943.         bra.w    snd_high_no_I_f
  8944.  
  8945.         move.b    sound_I_f_envelope,d6
  8946.         beq.w    snd_high_no_I_f
  8947.         cmp.b    #2,d6
  8948.         beq.s    snd_high_continue_I_f
  8949.  
  8950.         clr.b    sound_I_f_envelope        ;no further operations??
  8951.  
  8952.         move.l    a2,a6
  8953.         add.l    #$ff10,a6
  8954.         move.b    (a6),d7
  8955.         and.l    #%1110000,d7
  8956.         beq.w    snd_high_no_I_f
  8957.  
  8958. ;        bchg.b    #1,$bfe001
  8959. ;        move.w    #0,$dff180
  8960.  
  8961.         lsr.b    #4,d7
  8962.         mulu.w    #72,d7
  8963.         move.l    d7,sound_I_f_envelope_counter_base
  8964.         move.l    d7,sound_I_f_envelope_counter
  8965.         move.b    #2,sound_I_f_envelope
  8966.  
  8967.         move.w    3(a6),d7
  8968.         ror.w    #8,d7
  8969.         and.l    #%11111111111,d7
  8970.         move.l    d7,sound_I_f_initial_frequency
  8971.  
  8972.         bra.w    snd_high_no_I_f
  8973.  
  8974. snd_high_continue_I_f:
  8975.         subq.l    #1,sound_I_f_envelope_counter
  8976.         bne.s    snd_high_no_I_f
  8977.  
  8978.         move.l    sound_I_f_envelope_counter_base,sound_I_f_envelope_counter
  8979.  
  8980.         move.l    a2,a6
  8981.         add.l    #$ff10,a6
  8982.         move.b    (a6),d6
  8983.  
  8984.         move.l    sound_I_f_initial_frequency,d7
  8985.  
  8986.         btst    #3,d6
  8987.         beq.s    snd_high_continue_I_f_add
  8988.  
  8989. snd_high_continue_I_f_sub:
  8990.         and.b    #%111,d6
  8991.         lsr.l    d6,d7
  8992.         sub.l    d7,sound_I_f_initial_frequency
  8993.         bra.s    snd_high_continue_I_f_change
  8994.  
  8995. snd_high_continue_I_f_add:
  8996.         and.b    #%111,d6
  8997.         lsr.l    d6,d7
  8998.         add.l    d7,sound_I_f_initial_frequency
  8999.  
  9000. snd_high_continue_I_f_change:
  9001.         movem.l    d0-d2/a0-a2,-(SP)
  9002.  
  9003.         move.l    ahi_base,a6
  9004.         moveq.l    #0,d0
  9005.         move.l    sound_I_f_initial_frequency,d1
  9006.  
  9007.                 moveq.l #1,d2
  9008. ;        moveq.l    #0,d2
  9009. ;        bset    #AHISB_IMM,d2
  9010.         move.l    ahi_audio_ctrl,a2
  9011.         jsr    AHI_SetFreq(a6)
  9012.  
  9013.         movem.l    (SP)+,d0-d2/a0-a2
  9014.  
  9015. snd_high_no_I_f:
  9016.  
  9017. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9018. ;        volume envelopes
  9019. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9020.  
  9021.         move.b    sound_I_v_envelope,d6
  9022.         beq.w    snd_high_no_I
  9023.         cmp.b    #2,d6
  9024.         beq.s    snd_high_continue_I
  9025.  
  9026.         clr.b    sound_I_v_envelope        ;no further operations??
  9027.  
  9028.         move.l    a2,a6
  9029.         add.l    #$ff12,a6
  9030.         move.b    (a6),d7
  9031.         move.b    d7,d6
  9032.         and.l    #%111,d7
  9033.         beq.w    snd_high_no_I
  9034.  
  9035.         lsr.b    #4,d6
  9036.         move.b    d6,sound_I_v_envelope_initial_volume
  9037.  
  9038.         mulu.w    #144,d7
  9039.         move.l    d7,sound_I_v_envelope_counter_base
  9040.         move.l    d7,sound_I_v_envelope_counter
  9041.         move.b    #2,sound_I_v_envelope        ;sweep is on!
  9042.         bra.w    snd_high_no_I
  9043.  
  9044. snd_high_continue_I:
  9045.         subq.l    #1,sound_I_v_envelope_counter
  9046.         bne.w    snd_high_no_I
  9047.  
  9048.         move.l    sound_I_v_envelope_counter_base,sound_I_v_envelope_counter
  9049.         move.b    sound_I_v_envelope_initial_volume,d7
  9050.  
  9051.         move.l    a2,a6
  9052.         add.l    #$ff00,a6
  9053.         btst.b    #3,$12(a6)
  9054.         beq.s    snd_high_I_dec
  9055.  
  9056. snd_high_I_inc:    add.b    #1,d7
  9057.         cmp.b    #16,d7
  9058.         bne.s    snd_high_I_new_volume
  9059.  
  9060.         clr.b    sound_I_v_envelope
  9061.  
  9062.         btst.b    #6,$14(a6)
  9063.         beq.w    snd_high_no_I
  9064.  
  9065. snd_high_I_off:    movem.l    d0-d3/a0-a2,-(SP)
  9066.  
  9067.         move.l    ahi_base,a6
  9068.         moveq.l    #0,d0
  9069.         moveq.l    #0,d1
  9070.         move.l    sound_I_pan,d2
  9071.  
  9072.                 moveq.l #1,d3
  9073. ;        moveq.l    #0,d3
  9074. ;        bset    #AHISB_IMM,d3
  9075.         move.l    ahi_audio_ctrl,a2
  9076.         jsr    AHI_SetVol(a6)
  9077.  
  9078.         movem.l    (SP)+,d0-d3/a0-a2
  9079.         bra.s    snd_high_no_I
  9080.  
  9081. snd_high_I_dec:    subq.b    #1,d7
  9082.         bge.s    snd_high_I_new_volume
  9083.  
  9084.         clr.b    sound_I_v_envelope
  9085.         bra.s    snd_high_no_I
  9086.  
  9087. snd_high_I_new_volume:
  9088.         move.b    d7,sound_I_v_envelope_initial_volume
  9089.  
  9090.         movem.l    d0-d3/a0-a2,-(SP)
  9091.  
  9092.         and.w    #%1111,d7
  9093.         lea    sound_env_volumes,a6
  9094.         move.l    (a6,d7.w*4),sound_I_v
  9095.  
  9096.         move.l    ahi_base,a6
  9097.         moveq.l    #0,d0
  9098.         moveq.l    #0,d1
  9099.         tst.l    sound_I_status
  9100.         bne.s    no_s_I_addk
  9101.         move.l    sound_I_v,d1
  9102. no_s_I_addk:    move.l    sound_I_pan,d2
  9103.  
  9104.                 moveq.l #1,d3
  9105. ;        moveq.l    #0,d3
  9106. ;        bset    #AHISB_IMM,d3
  9107.         move.l    ahi_audio_ctrl,a2
  9108.         jsr    AHI_SetVol(a6)
  9109.  
  9110.         movem.l    (SP)+,d0-d3/a0-a2
  9111.  
  9112. snd_high_no_I:    
  9113.  
  9114. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9115. ;        channel 2 envelope
  9116. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9117.  
  9118.         move.b    sound_II_v_envelope,d6
  9119.         beq.w    snd_high_no_II
  9120.         cmp.b    #2,d6
  9121.         beq.s    snd_high_continue_II
  9122.  
  9123.         clr.b    sound_II_v_envelope        ;no further operations??
  9124.  
  9125.         move.l    a2,a6
  9126.         add.l    #$ff17,a6
  9127.         move.b    (a6),d7
  9128.         move.b    d7,d6
  9129.         and.l    #%111,d7
  9130.         beq.w    snd_high_no_II
  9131.  
  9132.         lsr.b    #4,d6
  9133.         move.b    d6,sound_II_v_envelope_initial_volume
  9134.  
  9135.         mulu.w    #144,d7
  9136.         move.l    d7,sound_II_v_envelope_counter_base
  9137.         move.l    d7,sound_II_v_envelope_counter
  9138.         move.b    #2,sound_II_v_envelope        ;sweep is on!
  9139.         bra.w    snd_high_no_II
  9140.  
  9141. snd_high_continue_II:
  9142.         subq.l    #1,sound_II_v_envelope_counter
  9143.         bne.w    snd_high_no_II
  9144.  
  9145.         move.l    sound_II_v_envelope_counter_base,sound_II_v_envelope_counter
  9146.         move.b    sound_II_v_envelope_initial_volume,d7
  9147.  
  9148.         move.l    a2,a6
  9149.         add.l    #$ff00,a6
  9150.         btst.b    #3,$17(a6)
  9151.         beq.s    snd_high_II_dec
  9152.  
  9153. snd_high_II_inc:add.b    #1,d7
  9154.         cmp.b    #16,d7
  9155.         bne.s    snd_high_II_new_volume
  9156.  
  9157.         clr.b    sound_II_v_envelope
  9158.  
  9159.         btst.b    #6,$19(a6)
  9160.         beq.w    snd_high_no_II
  9161.  
  9162. snd_high_II_off:movem.l    d0-d3/a0-a2,-(SP)
  9163.  
  9164.         move.l    ahi_base,a6
  9165.         moveq.l    #1,d0
  9166.         moveq.l    #0,d1
  9167.         move.l    sound_II_pan,d2
  9168.  
  9169.                 moveq.l #1,d3
  9170. ;        moveq.l    #0,d3
  9171. ;        bset    #AHISB_IMM,d3
  9172.         move.l    ahi_audio_ctrl,a2
  9173.         jsr    AHI_SetVol(a6)
  9174.  
  9175.         movem.l    (SP)+,d0-d3/a0-a2
  9176.         bra.s    snd_high_no_II
  9177.  
  9178. snd_high_II_dec:subq.b    #1,d7
  9179.         bge.s    snd_high_II_new_volume
  9180.  
  9181.         clr.b    sound_II_v_envelope
  9182.         bra.s    snd_high_no_II
  9183.  
  9184. snd_high_II_new_volume:
  9185.         move.b    d7,sound_II_v_envelope_initial_volume
  9186.  
  9187.         movem.l    d0-d3/a0-a2,-(SP)
  9188.  
  9189.         and.w    #%1111,d7
  9190.         lea    sound_env_volumes,a6
  9191.         move.l    (a6,d7.w*4),sound_II_v
  9192.  
  9193.         move.l    ahi_base,a6
  9194.         moveq.l    #1,d0
  9195.         moveq.l    #0,d1
  9196.         tst.l    sound_II_status
  9197.         bne.s    no_s_II_addk
  9198.         move.l    sound_II_v,d1
  9199. no_s_II_addk:    move.l    sound_II_pan,d2
  9200.  
  9201.                 moveq.l #1,d3
  9202. ;        moveq.l    #0,d3
  9203. ;        bset    #AHISB_IMM,d3
  9204.         move.l    ahi_audio_ctrl,a2
  9205.         jsr    AHI_SetVol(a6)
  9206.  
  9207.         movem.l    (SP)+,d0-d3/a0-a2
  9208.  
  9209. snd_high_no_II:
  9210.  
  9211. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9212. ;        channel 4 envelope
  9213. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9214.  
  9215.         move.b    sound_IV_v_envelope,d6
  9216.         beq.w    snd_high_no_IV
  9217.         cmp.b    #2,d6
  9218.         beq.s    snd_high_continue_IV
  9219.  
  9220.         clr.b    sound_IV_v_envelope        ;no further operations??
  9221.  
  9222.         move.l    a2,a6
  9223.         add.l    #$ff21,a6
  9224.         move.b    (a6),d7
  9225.         move.b    d7,d6
  9226.         and.l    #%111,d7
  9227.         beq.w    snd_high_no_IV
  9228.  
  9229.         lsr.b    #4,d6
  9230.         move.b    d6,sound_IV_v_envelope_initial_volume
  9231.  
  9232.         mulu.w    #144,d7
  9233.         move.l    d7,sound_IV_v_envelope_counter_base
  9234.         move.l    d7,sound_IV_v_envelope_counter
  9235.         move.b    #2,sound_IV_v_envelope        ;sweep is on!
  9236.         bra.w    snd_high_no_IV
  9237.  
  9238. snd_high_continue_IV:
  9239.         subq.l    #1,sound_IV_v_envelope_counter
  9240.         bne.w    snd_high_no_IV
  9241.  
  9242.         move.l    sound_IV_v_envelope_counter_base,sound_IV_v_envelope_counter
  9243.         move.b    sound_IV_v_envelope_initial_volume,d7
  9244.  
  9245.         move.l    a2,a6
  9246.         add.l    #$ff00,a6
  9247.         btst.b    #3,$21(a6)
  9248.         beq.s    snd_high_IV_dec
  9249.  
  9250. snd_high_IV_inc:add.b    #1,d7
  9251.         cmp.b    #16,d7
  9252.         bne.s    snd_high_IV_new_volume
  9253.  
  9254.         clr.b    sound_IV_v_envelope
  9255.  
  9256.         btst.b    #6,$23(a6)
  9257.         beq.w    snd_high_no_IV
  9258.  
  9259. snd_high_IV_off:movem.l    d0-d3/a0-a2,-(SP)
  9260.  
  9261.         move.l    ahi_base,a6
  9262.         moveq.l    #3,d0
  9263.         moveq.l    #0,d1
  9264.         move.l    sound_IV_pan,d2
  9265.  
  9266.                 moveq.l #1,d3
  9267. ;        moveq.l    #0,d3
  9268. ;        bset    #AHISB_IMM,d3
  9269.         move.l    ahi_audio_ctrl,a2
  9270.         jsr    AHI_SetVol(a6)
  9271.  
  9272.         movem.l    (SP)+,d0-d3/a0-a2
  9273.         bra.s    snd_high_no_IV
  9274.  
  9275. snd_high_IV_dec:subq.b    #1,d7
  9276.         bge.s    snd_high_IV_new_volume
  9277.  
  9278.         clr.b    sound_IV_v_envelope
  9279.         bra.s    snd_high_no_IV
  9280.  
  9281. snd_high_IV_new_volume:
  9282.         move.b    d7,sound_IV_v_envelope_initial_volume
  9283.  
  9284.         movem.l    d0-d3/a0-a2,-(SP)
  9285.  
  9286.         and.w    #%1111,d7
  9287.         lea    sound_env_volumes,a6
  9288.         move.l    (a6,d7.w*4),sound_IV_v
  9289.  
  9290.         move.l    ahi_base,a6
  9291.         moveq.l    #3,d0
  9292.         moveq.l    #0,d1
  9293.         tst.l    sound_IV_status
  9294.         bne.s    no_s_IV_addk
  9295.         move.l    sound_IV_v,d1
  9296. no_s_IV_addk:    move.l    sound_IV_pan,d2
  9297.  
  9298.                 moveq.l #1,d3
  9299. ;        moveq.l    #0,d3
  9300. ;        bset    #AHISB_IMM,d3
  9301.         move.l    ahi_audio_ctrl,a2
  9302.         jsr    AHI_SetVol(a6)
  9303.  
  9304.         movem.l    (SP)+,d0-d3/a0-a2
  9305.  
  9306. snd_high_no_IV:    bra.w    snd_high_back
  9307.  
  9308. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9309. ;        fill the RAM with predefined values
  9310. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9311.  
  9312. gb_memory_at_start:
  9313.         move.l    gb_memory,a0
  9314.         add.l    #$ff00,a0
  9315.  
  9316.         move.b    #$CF,$00(a0)
  9317.         move.b    #$00,$01(a0)
  9318.         move.b    #$7E,$02(a0)
  9319.         move.b    #$FF,$03(a0)
  9320.         move.b    #$AB,$04(a0)
  9321.         move.b    #$00,$05(a0)
  9322.         move.b    #$00,$06(a0)
  9323.         move.b    #%11111000,$07(a0)
  9324.  
  9325.         move.b    #$FF,$08(a0)
  9326.         move.b    #$FF,$09(a0)
  9327.         move.b    #$FF,$0A(a0)
  9328.         move.b    #$FF,$0B(a0)
  9329.         move.b    #$FF,$0C(a0)
  9330.         move.b    #$FF,$0D(a0)
  9331.         move.b    #$FF,$0E(a0)
  9332.  
  9333.         move.b    #$E1,$0F(a0)
  9334.         move.b    #$80,$10(a0)
  9335.         move.b    #$BF,$11(a0)
  9336.         move.b    #$F3,$12(a0)
  9337.         move.b    #$FF,$13(a0)
  9338.         move.b    #$BF,$14(a0)
  9339.         move.b    #$FF,$15(a0)
  9340.         move.b    #$3F,$16(a0)
  9341.         move.b    #$00,$17(a0)
  9342.         move.b    #$FF,$18(a0)
  9343.         move.b    #$BF,$19(a0)
  9344.         move.b    #$7F,$1A(a0)
  9345.         move.b    #$FF,$1B(a0)
  9346.         move.b    #$9F,$1C(a0)
  9347.         move.b    #$FF,$1D(a0)
  9348.         move.b    #$BF,$1E(a0)
  9349.         move.b    #$FF,$1F(a0)
  9350.         move.b    #$FF,$20(a0)
  9351.         move.b    #$00,$21(a0)
  9352.         move.b    #$00,$22(a0)
  9353.         move.b    #$BF,$23(a0)
  9354.         move.b    #$77,$24(a0)
  9355.         move.b    #$F3,$25(a0)
  9356.         move.b    #$F1,$26(a0)
  9357.  
  9358.         move.b    #$00,$27(a0)
  9359.         move.b    #$00,$28(a0)
  9360.         move.b    #$00,$29(a0)
  9361.         move.b    #$00,$2A(a0)
  9362.         move.b    #$00,$2B(a0)
  9363.         move.b    #$00,$2C(a0)
  9364.         move.b    #$00,$2D(a0)
  9365.         move.b    #$00,$2E(a0)
  9366.         move.b    #$00,$2F(a0)
  9367.  
  9368.         move.b    #$06,$30(a0)        ;cgb like wave ram init.
  9369.         move.b    #$FE,$31(a0)
  9370.         move.b    #$0E,$32(a0)
  9371.         move.b    #$7F,$33(a0)
  9372.         move.b    #$00,$34(a0)
  9373.         move.b    #$FF,$35(a0)
  9374.         move.b    #$58,$36(a0)
  9375.         move.b    #$DF,$37(a0)
  9376.         move.b    #$00,$38(a0)
  9377.         move.b    #$EC,$39(a0)
  9378.         move.b    #$00,$3A(a0)
  9379.         move.b    #$BF,$3B(a0)
  9380.         move.b    #$0C,$3C(a0)
  9381.         move.b    #$ED,$3D(a0)
  9382.         move.b    #$03,$3E(a0)
  9383.         move.b    #$F7,$3F(a0)
  9384.  
  9385.         move.b    #$91,$40(a0)
  9386.         move.b    #%10000000,$41(a0)
  9387.         move.b    #$00,$42(a0)
  9388.         move.b    #$00,$43(a0)
  9389.         move.b    #$00,$45(a0)
  9390.         move.b    #$FF,$46(a0)
  9391.         move.b    #$FC,$47(a0)
  9392.         move.b    #$FF,$48(a0)
  9393.         move.b    #$FF,$49(a0)
  9394.         move.b    #$00,$4A(a0)
  9395.         move.b    #$00,$4B(a0)
  9396.         move.b    #$00,$FF(a0)
  9397.  
  9398.         clr.b    sound_I_onf_master
  9399.         clr.b    sound_II_onf_master
  9400.         clr.b    sound_III_onf_master
  9401.         clr.b    sound_IV_onf_master
  9402.  
  9403.         clr.b    irq_status_flags
  9404.  
  9405.         clr.b    mbc1_ram_protection_status
  9406.         clr.b    mbc2_ram_protection_status
  9407.         clr.b    mbc3_ram_protection_status
  9408.         clr.b    mbc3_latched_sec
  9409.         clr.b    mbc3_latched_min
  9410.         clr.b    mbc3_latched_hrs
  9411.         clr.b    mbc3_latched_dayl
  9412.         clr.b    mbc3_latched_dayh
  9413.         clr.b    mbc3_sec
  9414.         clr.b    mbc3_min
  9415.         clr.b    mbc3_hrs
  9416.         clr.b    mbc3_dayl
  9417.         clr.b    mbc3_dayh
  9418.         clr.b    mbc3_latch_a
  9419.         clr.b    mbc3_latch_b
  9420.         clr.b    mbc5_rom_bank
  9421.         clr.b    mbc5_rom_bank1
  9422.         clr.b    mbc5_rom_bank0
  9423.  
  9424.         clr.l    freq_storage
  9425.         rts
  9426.  
  9427. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9428. ;        interrupt debugging
  9429. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9430.  
  9431.         IFGT    GAMEBOY_DEBUG
  9432.  
  9433. debug_vbr:    movem.l    d0-d7/a0-a6,-(SP)
  9434.  
  9435.         move.l    #debug_vbr_txt,d2
  9436.         move.l    #debug_vbr_txt_end-debug_vbr_txt,d3
  9437.         move.l    dos_base,a6
  9438.         move.l    debug_con_handle,d1
  9439.         jsr    Write(a6)
  9440.  
  9441.         movem.l    (SP)+,d0-d7/a0-a6
  9442.         rts
  9443.  
  9444. debug_lcd:    movem.l    d0-d7/a0-a6,-(SP)
  9445.  
  9446.         move.l    #debug_lcd_txt,d2
  9447.         move.l    #debug_lcd_txt_end-debug_lcd_txt,d3
  9448.         move.l    dos_base,a6
  9449.         move.l    debug_con_handle,d1
  9450.         jsr    Write(a6)
  9451.  
  9452.         movem.l    (SP)+,d0-d7/a0-a6
  9453.         rts
  9454.  
  9455. debug_timer:    movem.l    d0-d7/a0-a6,-(SP)
  9456.  
  9457.         move.l    #debug_timer_txt,d2
  9458.         move.l    #debug_timer_txt_end-debug_timer_txt,d3
  9459.         move.l    dos_base,a6
  9460.         move.l    debug_con_handle,d1
  9461.         jsr    Write(a6)
  9462.  
  9463.         movem.l    (SP)+,d0-d7/a0-a6
  9464.         rts
  9465.  
  9466. debug_p10:    movem.l    d0-d7/a0-a6,-(SP)
  9467.  
  9468.         move.l    #debug_p10_txt,d2
  9469.         move.l    #debug_p10_txt_end-debug_p10_txt,d3
  9470.         move.l    dos_base,a6
  9471.         move.l    debug_con_handle,d1
  9472.         jsr    Write(a6)
  9473.  
  9474.         movem.l    (SP)+,d0-d7/a0-a6
  9475.         rts
  9476.  
  9477. debug_blank:    movem.l    d0-d7/a0-a6,-(SP)
  9478.  
  9479.         move.l    #debug_blank_txt,d2
  9480.         move.l    #debug_blank_txt_end-debug_blank_txt,d3
  9481.         move.l    dos_base,a6
  9482.         move.l    debug_con_handle,d1
  9483.         jsr    Write(a6)
  9484.  
  9485.         movem.l    (SP)+,d0-d7/a0-a6
  9486.         rts
  9487.  
  9488.         ENDIF
  9489.  
  9490. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9491. ;        output scanline number
  9492. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9493.  
  9494.         IFGT    GAMEBOY_DEBUG
  9495.  
  9496. debug_scanline_out:
  9497.         movem.l    d0-d7/a0-a6,-(SP)
  9498.  
  9499.         lea    debug_scanline,a1
  9500.         move.l    gb_scanlines,d0
  9501.         lsr.w    #8,d0
  9502.         tput_d0_to_a1
  9503.         move.l    gb_scanlines,d0
  9504.         tput_d0_to_a1
  9505.  
  9506.         move.l    #debug_scanline_message,d2
  9507.         move.l    #debug_scanline_message_end-debug_scanline_message,d3
  9508.         move.l    dos_base,a6
  9509.         move.l    debug_con_handle,d1
  9510.         jsr    Write(a6)
  9511.  
  9512.         movem.l    (SP)+,d0-d7/a0-a6
  9513.         rts
  9514.  
  9515.         ENDIF
  9516.  
  9517. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9518. ;        use value y to update the sound registers
  9519. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9520.  
  9521. sfx_update_all:    tst.b    snd_master
  9522.         bne.w    sfx_back
  9523.  
  9524.         move.l    sfx_y_adder,d0
  9525.         add.l    d0,sfx_y_actual_value
  9526.         move.l    sfx_y_actual_value,d1
  9527.         swap    d1
  9528.         tst.w    d1
  9529.         beq.w    sfx_back
  9530.         sub.l    #$10000,sfx_y_actual_value
  9531.  
  9532. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9533. ;        update sound register values
  9534. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9535.  
  9536.         move.l    gb_memory,a5
  9537.         add.l    #$ff00,a5
  9538.         move.l    ahi_base,a6
  9539.  
  9540.         move.b    $26(a5),d6
  9541.         btst    #7,d6
  9542.         bne.s    sounds_on_go
  9543.  
  9544. sounds_off_go:    moveq.l    #0,d0
  9545.         moveq.l    #0,d1
  9546.         move.l    sound_I_pan,d2
  9547.  
  9548.                 moveq.l #1,d3
  9549. ;        moveq.l    #0,d3
  9550. ;        bset    #AHISB_IMM,d3
  9551.         move.l    ahi_audio_ctrl,a2
  9552.         jsr    AHI_SetVol(a6)
  9553.  
  9554.         moveq.l    #1,d0
  9555.         moveq.l    #0,d1
  9556.         move.l    sound_II_pan,d2
  9557.  
  9558.                 moveq.l #1,d3
  9559. ;        moveq.l    #0,d3
  9560. ;        bset    #AHISB_IMM,d3
  9561.         move.l    ahi_audio_ctrl,a2
  9562.         jsr    AHI_SetVol(a6)
  9563.  
  9564.         moveq.l    #2,d0
  9565.         moveq.l    #0,d1
  9566.         move.l    sound_III_pan,d2
  9567.  
  9568.                 moveq.l #1,d3
  9569. ;        moveq.l    #0,d3
  9570. ;        bset    #AHISB_IMM,d3
  9571.         move.l    ahi_audio_ctrl,a2
  9572.         jsr    AHI_SetVol(a6)
  9573.  
  9574.         moveq.l    #3,d0
  9575.         moveq.l    #0,d1
  9576.         move.l    sound_IV_pan,d2
  9577.  
  9578.                 moveq.l #1,d3
  9579. ;        moveq.l    #0,d3
  9580. ;        bset    #AHISB_IMM,d3
  9581.         move.l    ahi_audio_ctrl,a2
  9582.         jsr    AHI_SetVol(a6)
  9583.  
  9584.         bra.w    sfx_back
  9585.  
  9586. sounds_on_go:    move.b    $25(a5),d6
  9587.  
  9588.         lea    pan_table,a4
  9589.         lea    onf_table,a2
  9590.         moveq.l    #0,d7
  9591.  
  9592.         move.b    d6,d7
  9593.         and.b    #%10001,d7
  9594.         move.b    d7,d0
  9595.         lsr.b    #3,d7
  9596.         and.b    #%1,d0
  9597.         or.b    d0,d7
  9598.         move.l    (a4,d7.w*4),sound_I_pan
  9599.         move.b    (a2,d7.w),sound_I_onf
  9600.  
  9601.         move.b    d6,d7
  9602.         and.b    #%100010,d7
  9603.         lsr.b    #1,d7
  9604.         move.b    d7,d0
  9605.         lsr.b    #3,d7
  9606.         and.b    #%1,d0
  9607.         or.b    d0,d7
  9608.         move.l    (a4,d7.w*4),sound_II_pan
  9609.         move.b    (a2,d7.w),sound_II_onf
  9610.  
  9611.         move.b    d6,d7
  9612.         and.b    #%1000100,d7
  9613.         lsr.b    #2,d7
  9614.         move.b    d7,d0
  9615.         lsr.b    #3,d7
  9616.         and.b    #%1,d0
  9617.         or.b    d0,d7
  9618.         move.l    (a4,d7.w*4),sound_III_pan
  9619.         move.b    (a2,d7.w),sound_III_onf
  9620.  
  9621.         and.l    #%10001000,d6
  9622.         lsr.b    #3,d6
  9623.         move.b    d6,d0
  9624.         lsr.b    #3,d6
  9625.         and.b    #%1,d0
  9626.         or.b    d0,d6
  9627.         move.l    (a4,d6.w*4),sound_IV_pan
  9628.         move.b    (a2,d6.w),sound_IV_onf
  9629.  
  9630. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9631. ;        channel 1
  9632. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9633.  
  9634.         tst.b    snd_chnlI
  9635.         bne.w    no_chnlI_no_no
  9636.  
  9637.         moveq.l    #0,d7
  9638.         move.b    $12(a5),d7
  9639.         lsr.b    #4,d7
  9640.         lea    sound_env_volumes,a2
  9641.         move.l    (a2,d7.w*4),sound_I_v
  9642.  
  9643.         moveq.l    #0,d0
  9644.         moveq.l    #0,d1
  9645.         tst.b    sound_I_onf
  9646.         bne.s    no_s_I_addb
  9647.         move.l    sound_I_v,d1
  9648. no_s_I_addb:    move.l    sound_I_pan,d2
  9649.  
  9650.                 moveq.l #1,d3
  9651. ;        moveq.l    #0,d3
  9652. ;        bset    #AHISB_IMM,d3
  9653.         move.l    ahi_audio_ctrl,a2
  9654.         jsr    AHI_SetVol(a6)
  9655.  
  9656.         move.w    $13(a5),d7
  9657.         and.l    #%1111111100000111,d7
  9658.         ror.w    #8,d7
  9659.  
  9660.         move.l    #2048,d2
  9661.         move.l    #131072,d1
  9662.         sub.l    d7,d2
  9663.         divu.l    d2,d1
  9664.         lsl.l    #3,d1
  9665.         and.l    #%111111111111111111,d1
  9666.         move.l    d1,sound_I_f
  9667.  
  9668.         moveq.l    #0,d0
  9669.  
  9670.                 moveq.l #1,d2
  9671. ;        moveq.l    #0,d2
  9672. ;        bset    #AHISB_IMM,d2
  9673.         move.l    ahi_audio_ctrl,a2
  9674.         jsr    AHI_SetFreq(a6)
  9675.  
  9676.         moveq.l    #0,d6
  9677.         move.b    $11(a5),d6
  9678.         lsr.b    #6,d6
  9679.         cmp.b    old_sound_I_duty,d6
  9680.         beq.w    no_chnlI_no_no
  9681.  
  9682.         move.b    d6,old_sound_I_duty
  9683.  
  9684.         moveq.l    #0,d0
  9685.         move.l    ahi_audio_ctrl,a2
  9686.         jsr    AHI_UnloadSound(a6)
  9687.  
  9688.         move.l    smpl_info_I,a0
  9689.         lea    smpl_mem_1,a1
  9690.         move.l    (a1,d6.w*4),ahisi_Address(a0)    ;address.
  9691.  
  9692.         moveq.l    #0,d0                ;sample number.
  9693.         move.l    #AHIST_SAMPLE,d1        ;type.
  9694.         move.l    smpl_info_I,a0            ;info field.
  9695.         move.l    ahi_audio_ctrl,a2        ;ctrl.
  9696.         jsr    AHI_LoadSound(a6)
  9697.  
  9698.         moveq.l    #0,d0                ;channel.
  9699.         moveq.l    #0,d1                ;sample.
  9700.         moveq.l    #0,d2                ;offset.
  9701.         move.l    #8*512,d3            ;size (full).
  9702.  
  9703.                 moveq.l #1,d4
  9704. ;        moveq.l    #0,d4
  9705. ;        bset    #AHISB_IMM,d4            ;flags.
  9706.         move.l    ahi_audio_ctrl,a2
  9707.         jsr    AHI_SetSound(a6)
  9708.  
  9709.         moveq.l    #0,d0
  9710.         move.l    sound_I_f,d1
  9711.  
  9712.                 moveq.l #1,d2
  9713. ;        moveq.l    #0,d2
  9714. ;        bset    #AHISB_IMM,d2
  9715.         move.l    ahi_audio_ctrl,a2
  9716.         jsr    AHI_SetFreq(a6)
  9717.  
  9718.         moveq.l    #0,d0
  9719.         moveq.l    #0,d1
  9720.         tst.b    sound_I_onf
  9721.         bne.s    no_s_I_addd
  9722.         move.l    sound_I_v,d1
  9723. no_s_I_addd:    move.l    sound_I_pan,d2
  9724.  
  9725.                 moveq.l #1,d3
  9726. ;        moveq.l    #0,d3
  9727. ;        bset    #AHISB_IMM,d3
  9728.         move.l    ahi_audio_ctrl,a2
  9729.         jsr    AHI_SetVol(a6)
  9730.  
  9731. no_chnlI_no_no:    
  9732.  
  9733. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9734. ;        channel 2
  9735. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9736.  
  9737.         tst.b    snd_chnlII
  9738.         bne.w    no_chnlII_no_no
  9739.  
  9740.         moveq.l    #0,d7
  9741.         move.b    $17(a5),d7
  9742.         lsr.b    #4,d7
  9743.         lea    sound_env_volumes,a2
  9744.         move.l    (a2,d7.w*4),sound_II_v
  9745.  
  9746.         moveq.l    #1,d0
  9747.         moveq.l    #0,d1
  9748.         tst.b    sound_II_onf
  9749.         bne.s    no_s_II_addb
  9750.         move.l    sound_II_v,d1
  9751. no_s_II_addb:    move.l    sound_II_pan,d2
  9752.  
  9753.                 moveq.l #1,d3
  9754. ;        moveq.l    #0,d3
  9755. ;        bset    #AHISB_IMM,d3
  9756.         move.l    ahi_audio_ctrl,a2
  9757.         jsr    AHI_SetVol(a6)
  9758.  
  9759.         move.w    $18(a5),d7
  9760.         and.l    #%1111111100000111,d7
  9761.         ror.w    #8,d7
  9762.  
  9763.         move.l    #2048,d2
  9764.         move.l    #131072,d1
  9765.         sub.l    d7,d2
  9766.         divu.l    d2,d1
  9767.         lsl.l    #3,d1
  9768.         and.l    #%111111111111111111,d1
  9769.         move.l    d1,sound_II_f
  9770.  
  9771.         moveq.l    #1,d0
  9772.  
  9773.                 moveq.l #1,d2
  9774. ;        moveq.l    #0,d2
  9775. ;        bset    #AHISB_IMM,d2
  9776.         move.l    ahi_audio_ctrl,a2
  9777.         jsr    AHI_SetFreq(a6)
  9778.  
  9779.         moveq.l    #0,d6
  9780.         move.b    $16(a5),d6
  9781.         lsr.b    #6,d6
  9782.         cmp.b    old_sound_II_duty,d6
  9783.         beq.w    no_chnlII_no_no
  9784.  
  9785.         move.b    d6,old_sound_II_duty
  9786.  
  9787.         moveq.l    #1,d0
  9788.         move.l    ahi_audio_ctrl,a2
  9789.         jsr    AHI_UnloadSound(a6)
  9790.  
  9791.         move.l    smpl_info_II,a0
  9792.         lea    smpl_mem_1,a1
  9793.         move.l    (a1,d6.w*4),ahisi_Address(a0)    ;address.
  9794.  
  9795.         moveq.l    #1,d0                ;sample number.
  9796.         move.l    #AHIST_SAMPLE,d1        ;type.
  9797.         move.l    smpl_info_II,a0            ;info field.
  9798.         move.l    ahi_audio_ctrl,a2        ;ctrl.
  9799.         jsr    AHI_LoadSound(a6)
  9800.  
  9801.         moveq.l    #1,d0                ;channel.
  9802.         moveq.l    #1,d1                ;sample.
  9803.         moveq.l    #0,d2                ;offset.
  9804.         move.l    #8*512,d3            ;size (full).
  9805.  
  9806.                 moveq.l #1,d4
  9807. ;        moveq.l    #0,d4
  9808. ;        bset    #AHISB_IMM,d4            ;flags.
  9809.         move.l    ahi_audio_ctrl,a2
  9810.         jsr    AHI_SetSound(a6)
  9811.  
  9812.         moveq.l    #1,d0
  9813.         move.l    sound_II_f,d1
  9814.  
  9815.                 moveq.l #1,d2
  9816. ;        moveq.l    #0,d2
  9817. ;        bset    #AHISB_IMM,d2
  9818.         move.l    ahi_audio_ctrl,a2
  9819.         jsr    AHI_SetFreq(a6)
  9820.  
  9821.         moveq.l    #1,d0
  9822.         moveq.l    #0,d1
  9823.         tst.b    sound_II_onf
  9824.         bne.s    no_s_II_addd
  9825.         move.l    sound_II_v,d1
  9826. no_s_II_addd:    move.l    sound_II_pan,d2
  9827.  
  9828.                 moveq.l #1,d3
  9829. ;        moveq.l    #0,d3
  9830. ;        bset    #AHISB_IMM,d3
  9831.         move.l    ahi_audio_ctrl,a2
  9832.         jsr    AHI_SetVol(a6)
  9833.  
  9834. no_chnlII_no_no:
  9835.  
  9836. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9837. ;        channel 3
  9838. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9839.  
  9840.         tst.b    snd_chnlIII
  9841.         bne.w    no_chnlIII_no_no
  9842.  
  9843.         move.b    $1a(a5),d6
  9844.         and.b    #%10000000,d6
  9845.         bne.s    sound_III_on_on
  9846.  
  9847.         moveq.l    #2,d0
  9848.         moveq.l    #0,d1
  9849.         move.l    sound_III_pan,d2
  9850.  
  9851.                 moveq.l #1,d3
  9852. ;        moveq.l    #0,d3
  9853. ;        bset    #AHISB_IMM,d3
  9854.         move.l    ahi_audio_ctrl,a2
  9855.         jsr    AHI_SetVol(a6)
  9856.  
  9857.         bra.w    no_chnlIII_no_no
  9858.  
  9859. sound_III_on_on:lea    $30(a5),a4
  9860.         moveq.l    #16-1,d0
  9861.         move.l    sound_III_lst,a1
  9862.         move.l    smpl_III_mem,a3
  9863.         moveq.l    #0,d7
  9864. chnlIII_loop:    move.b    (a4)+,d7
  9865.         move.w    (a1,d7.w*2),(a3)+
  9866.         dbra    d0,chnlIII_loop
  9867.  
  9868.         move.b    $1c(a5),d6
  9869.         and.b    #%01100000,d6
  9870.  
  9871.         lsr.b    #3,d6
  9872.         and.l    #%1100,d6
  9873.         lea    sound_III_vol,a1
  9874.         move.l    (a1,d6.w),sound_III_v
  9875.  
  9876.         moveq.l    #2,d0
  9877.         moveq.l    #0,d1
  9878.         tst.b    sound_III_onf
  9879.         bne.s    no_s_III_addk
  9880.         move.l    sound_III_v,d1
  9881. no_s_III_addk:    move.l    sound_III_pan,d2
  9882.  
  9883.                 moveq.l #1,d3
  9884. ;        moveq.l    #0,d3
  9885. ;        bset    #AHISB_IMM,d3
  9886.         move.l    ahi_audio_ctrl,a2
  9887.         jsr    AHI_SetVol(a6)
  9888.  
  9889.         move.w    $1d(a5),d6
  9890.         and.l    #%1111111100000111,d6
  9891.         ror.w    #8,d6
  9892.  
  9893.         move.l    #131072/2,d1
  9894.         move.l    #2048,d2
  9895.         sub.l    d6,d2
  9896.         divu.l    d2,d1
  9897.         lsl.l    #5,d1
  9898.         and.l    #%111111111111111111,d1
  9899.  
  9900.         moveq.l    #2,d0
  9901.  
  9902.                 moveq.l #1,d2
  9903. ;        moveq.l    #0,d2
  9904. ;        bset    #AHISB_IMM,d2
  9905.         move.l    ahi_audio_ctrl,a2
  9906.         jsr    AHI_SetFreq(a6)
  9907.  
  9908. no_chnlIII_no_no:
  9909.  
  9910. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9911. ;        channel 4
  9912. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9913.  
  9914.         tst.b    snd_chnlIV
  9915.         bne.w    no_chnlIV_no_no
  9916.  
  9917.         moveq.l    #0,d7
  9918.         move.b    $21(a5),d7
  9919.         lsr.b    #4,d7
  9920.         lea    sound_env_volumes,a2
  9921.         move.l    (a2,d7.w*4),sound_IV_v
  9922.  
  9923.         moveq.l    #3,d0
  9924.         moveq.l    #0,d1
  9925.         tst.b    sound_IV_onf
  9926.         bne.s    no_s_IV_addh
  9927.         btst.b    #6,$23(a5)
  9928.         bne.s    no_s_IV_addh
  9929.         move.l    sound_IV_v,d1
  9930. no_s_IV_addh:    move.l    sound_IV_pan,d2
  9931.  
  9932.                 moveq.l #1,d3
  9933. ;        moveq.l    #0,d3
  9934. ;        bset    #AHISB_IMM,d3
  9935.         move.l    ahi_audio_ctrl,a2
  9936.         jsr    AHI_SetVol(a6)
  9937.  
  9938.         move.b    $22(a5),d6
  9939.         move.b    d6,d7
  9940.  
  9941.         lea    sound_4_freq_table,a0
  9942.         and.l    #%111,d6
  9943.         move.l    (a0,d6.w*4),d1
  9944.  
  9945.         lsr.b    #4,d7
  9946.         and.b    #%1111,d7
  9947.         addq.b    #1,d7
  9948.         lsr.l    d7,d1
  9949.  
  9950.         moveq.l    #3,d0
  9951.  
  9952.                 moveq.l #1,d2
  9953. ;        moveq.l    #0,d2
  9954. ;        bset    #AHISB_IMM,d2
  9955.         move.l    ahi_audio_ctrl,a2
  9956.         jsr    AHI_SetFreq(a6)
  9957.  
  9958. no_chnlIV_no_no:bra.w    sfx_back
  9959.  
  9960. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9961. ;        execute different interrupts
  9962. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  9963.  
  9964. prior_i_0:    btst.b    #7,$40(a6)            ;lcd on?
  9965.         beq.w    no_interrupts_0            ;no.
  9966.  
  9967.         bclr.b    #0,$0f(a6)
  9968.  
  9969.         IFEQ    Z80_MODE
  9970.         bsr.w    write_d6_stackx
  9971.         ELSE
  9972.         ror.w    #8,d6
  9973.         subq.w    #2,d5
  9974.         move.w    d6,(a2,d5.l)
  9975.         ENDIF
  9976.  
  9977.         lea    $40(a3),a0
  9978.         move.l    a3,z80_pc_base
  9979.         move.b    #1,i_flag
  9980.         clr.b    z80_halt
  9981.         bra.w    no_interrupts_0
  9982.  
  9983.         IFLE    Z80_MODE
  9984. prior_ii_0:    btst.b    #7,$40(a6)            ;lcd on?
  9985.         beq.w    no_interrupts_0            ;no.
  9986.  
  9987.         bclr.b    #1,$0f(a6)
  9988.  
  9989.         IFEQ    Z80_MODE
  9990.         bsr.w    write_d6_stackx
  9991.         ELSE
  9992.         ror.w    #8,d6
  9993.         subq.w    #2,d5
  9994.         move.w    d6,(a2,d5.l)
  9995.         ENDIF
  9996.  
  9997.         lea    $48(a3),a0
  9998.         move.l    a3,z80_pc_base
  9999.         move.b    #1,i_flag
  10000.         clr.b    z80_halt
  10001.         bra.w    no_interrupts_0
  10002.  
  10003. prior_iii_0:    bclr.b    #2,$0f(a6)
  10004.  
  10005.         IFEQ    Z80_MODE
  10006.         bsr.w    write_d6_stackx
  10007.         ELSE
  10008.         ror.w    #8,d6
  10009.         subq.w    #2,d5
  10010.         move.w    d6,(a2,d5.l)
  10011.         ENDIF
  10012.  
  10013.         lea    $50(a3),a0
  10014.         move.l    a3,z80_pc_base
  10015.         move.b    #1,i_flag
  10016.         clr.b    z80_halt
  10017.         bra.w    no_interrupts_0
  10018.         ENDIF
  10019.  
  10020. prior_iv_0:    bclr.b    #3,$0f(a6)
  10021.  
  10022.         IFEQ    Z80_MODE
  10023.         bsr.w    write_d6_stackx
  10024.         ELSE
  10025.         ror.w    #8,d6
  10026.         subq.w    #2,d5
  10027.         move.w    d6,(a2,d5.l)
  10028.         ENDIF
  10029.  
  10030.         lea    $58(a3),a0
  10031.         move.l    a3,z80_pc_base
  10032.         move.b    #1,i_flag
  10033.         clr.b    z80_halt
  10034.         bra.w    no_interrupts_0
  10035.  
  10036. prior_v_0:    bclr.b    #4,$0f(a6)
  10037.  
  10038.         IFEQ    Z80_MODE
  10039.         bsr.w    write_d6_stackx
  10040.         ELSE
  10041.         ror.w    #8,d6
  10042.         subq.w    #2,d5
  10043.         move.w    d6,(a2,d5.l)
  10044.         ENDIF
  10045.  
  10046.         lea    $60(a3),a0
  10047.         move.l    a3,z80_pc_base
  10048.         move.b    #1,i_flag
  10049.         clr.b    z80_halt
  10050.         bra.w    no_interrupts_0
  10051.  
  10052. prior_i_1:    btst.b    #7,$40(a6)            ;lcd on?
  10053.         beq.w    no_interrupts_1            ;no.
  10054.  
  10055.         bclr.b    #0,$0f(a6)
  10056.  
  10057.         IFEQ    Z80_MODE
  10058.         bsr.w    write_d6_stackx
  10059.         ELSE
  10060.         ror.w    #8,d6
  10061.         subq.w    #2,d5
  10062.         move.w    d6,(a2,d5.l)
  10063.         ENDIF
  10064.  
  10065.         lea    $40(a3),a0
  10066.         move.l    a3,z80_pc_base
  10067.         move.b    #1,i_flag
  10068.         clr.b    z80_halt
  10069.         bra.w    no_interrupts_1
  10070.  
  10071.         IFLE    Z80_MODE
  10072. prior_ii_1:    btst.b    #7,$40(a6)            ;lcd on?
  10073.         beq.w    no_interrupts_1            ;no.
  10074.  
  10075.         bclr.b    #1,$0f(a6)
  10076.  
  10077.         IFEQ    Z80_MODE
  10078.         bsr.w    write_d6_stackx
  10079.         ELSE
  10080.         ror.w    #8,d6
  10081.         subq.w    #2,d5
  10082.         move.w    d6,(a2,d5.l)
  10083.         ENDIF
  10084.  
  10085.         lea    $48(a3),a0
  10086.         move.l    a3,z80_pc_base
  10087.         move.b    #1,i_flag
  10088.         clr.b    z80_halt
  10089.         bra.w    no_interrupts_1
  10090.  
  10091. prior_iii_1:    bclr.b    #2,$0f(a6)
  10092.  
  10093.         IFEQ    Z80_MODE
  10094.         bsr.w    write_d6_stackx
  10095.         ELSE
  10096.         ror.w    #8,d6
  10097.         subq.w    #2,d5
  10098.         move.w    d6,(a2,d5.l)
  10099.         ENDIF
  10100.  
  10101.         lea    $50(a3),a0
  10102.         move.l    a3,z80_pc_base
  10103.         move.b    #1,i_flag
  10104.         clr.b    z80_halt
  10105.         bra.w    no_interrupts_1
  10106.         ENDIF
  10107.  
  10108. prior_iv_1:    bclr.b    #3,$0f(a6)
  10109.  
  10110.         IFEQ    Z80_MODE
  10111.         bsr.w    write_d6_stackx
  10112.         ELSE
  10113.         ror.w    #8,d6
  10114.         subq.w    #2,d5
  10115.         move.w    d6,(a2,d5.l)
  10116.         ENDIF
  10117.  
  10118.         lea    $58(a3),a0
  10119.         move.l    a3,z80_pc_base
  10120.         move.b    #1,i_flag
  10121.         clr.b    z80_halt
  10122.         bra.w    no_interrupts_1
  10123.  
  10124. prior_v_1:    bclr.b    #4,$0f(a6)
  10125.  
  10126.         IFEQ    Z80_MODE
  10127.         bsr.w    write_d6_stackx
  10128.         ELSE
  10129.         ror.w    #8,d6
  10130.         subq.w    #2,d5
  10131.         move.w    d6,(a2,d5.l)
  10132.         ENDIF
  10133.  
  10134.         lea    $60(a3),a0
  10135.         move.l    a3,z80_pc_base
  10136.         move.b    #1,i_flag
  10137.         clr.b    z80_halt
  10138.         bra.w    no_interrupts_1
  10139.  
  10140. prior_i_2:    btst.b    #7,$40(a6)            ;lcd on?
  10141.         beq.w    no_interrupts_2            ;no.
  10142.  
  10143.         bclr.b    #0,$0f(a6)
  10144.  
  10145.         IFEQ    Z80_MODE
  10146.         bsr.w    write_d6_stackx
  10147.         ELSE
  10148.         ror.w    #8,d6
  10149.         subq.w    #2,d5
  10150.         move.w    d6,(a2,d5.l)
  10151.         ENDIF
  10152.  
  10153.         lea    $40(a3),a0
  10154.         move.l    a3,z80_pc_base
  10155.         move.b    #1,i_flag
  10156.         clr.b    z80_halt
  10157.         bra.w    no_interrupts_2
  10158.  
  10159.         IFLE    Z80_MODE
  10160. prior_ii_2:    btst.b    #7,$40(a6)            ;lcd on?
  10161.         beq.w    no_interrupts_2            ;no.
  10162.  
  10163.         bclr.b    #1,$0f(a6)
  10164.  
  10165.         IFEQ    Z80_MODE
  10166.         bsr.w    write_d6_stackx
  10167.         ELSE
  10168.         ror.w    #8,d6
  10169.         subq.w    #2,d5
  10170.         move.w    d6,(a2,d5.l)
  10171.         ENDIF
  10172.  
  10173.         lea    $48(a3),a0
  10174.         move.l    a3,z80_pc_base
  10175.         move.b    #1,i_flag
  10176.         clr.b    z80_halt
  10177.         bra.w    no_interrupts_2
  10178.  
  10179. prior_iii_2:    bclr.b    #2,$0f(a6)
  10180.  
  10181.         IFEQ    Z80_MODE
  10182.         bsr.w    write_d6_stackx
  10183.         ELSE
  10184.         ror.w    #8,d6
  10185.         subq.w    #2,d5
  10186.         move.w    d6,(a2,d5.l)
  10187.         ENDIF
  10188.  
  10189.         lea    $50(a3),a0
  10190.         move.l    a3,z80_pc_base
  10191.         move.b    #1,i_flag
  10192.         clr.b    z80_halt
  10193.         bra.w    no_interrupts_2
  10194.         ENDIF
  10195.  
  10196. prior_iv_2:    bclr.b    #3,$0f(a6)
  10197.  
  10198.         IFEQ    Z80_MODE
  10199.         bsr.w    write_d6_stackx
  10200.         ELSE
  10201.         ror.w    #8,d6
  10202.         subq.w    #2,d5
  10203.         move.w    d6,(a2,d5.l)
  10204.         ENDIF
  10205.  
  10206.         lea    $58(a3),a0
  10207.         move.l    a3,z80_pc_base
  10208.         move.b    #1,i_flag
  10209.         clr.b    z80_halt
  10210.         bra.w    no_interrupts_2
  10211.  
  10212. prior_v_2:    bclr.b    #4,$0f(a6)
  10213.  
  10214.         IFEQ    Z80_MODE
  10215.         bsr.w    write_d6_stackx
  10216.         ELSE
  10217.         ror.w    #8,d6
  10218.         subq.w    #2,d5
  10219.         move.w    d6,(a2,d5.l)
  10220.         ENDIF
  10221.  
  10222.         lea    $60(a3),a0
  10223.         move.l    a3,z80_pc_base
  10224.         move.b    #1,i_flag
  10225.         clr.b    z80_halt
  10226.         bra.w    no_interrupts_2
  10227.  
  10228. prior_i_3:    btst.b    #7,$40(a6)            ;lcd on?
  10229.         beq.w    no_interrupts_3            ;no.
  10230.  
  10231.         bclr.b    #0,$0f(a6)
  10232.  
  10233.         IFEQ    Z80_MODE
  10234.         bsr.w    write_d6_stackx
  10235.         ELSE
  10236.         ror.w    #8,d6
  10237.         subq.w    #2,d5
  10238.         move.w    d6,(a2,d5.l)
  10239.         ENDIF
  10240.  
  10241.         lea    $40(a3),a0
  10242.         move.l    a3,z80_pc_base
  10243.         move.b    #1,i_flag
  10244.         clr.b    z80_halt
  10245.         bra.w    no_interrupts_3
  10246.  
  10247.         IFLE    Z80_MODE
  10248. prior_ii_3:    btst.b    #7,$40(a6)            ;lcd on?
  10249.         beq.w    no_interrupts_3            ;no.
  10250.  
  10251.         bclr.b    #1,$0f(a6)
  10252.  
  10253.         IFEQ    Z80_MODE
  10254.         bsr.w    write_d6_stackx
  10255.         ELSE
  10256.         ror.w    #8,d6
  10257.         subq.w    #2,d5
  10258.         move.w    d6,(a2,d5.l)
  10259.         ENDIF
  10260.  
  10261.         lea    $48(a3),a0
  10262.         move.l    a3,z80_pc_base
  10263.         move.b    #1,i_flag
  10264.         clr.b    z80_halt
  10265.         bra.w    no_interrupts_3
  10266.  
  10267. prior_iii_3:    bclr.b    #2,$0f(a6)
  10268.  
  10269.         IFEQ    Z80_MODE
  10270.         bsr.w    write_d6_stackx
  10271.         ELSE
  10272.         ror.w    #8,d6
  10273.         subq.w    #2,d5
  10274.         move.w    d6,(a2,d5.l)
  10275.         ENDIF
  10276.  
  10277.         lea    $50(a3),a0
  10278.         move.l    a3,z80_pc_base
  10279.         move.b    #1,i_flag
  10280.         clr.b    z80_halt
  10281.         bra.w    no_interrupts_3
  10282.         ENDIF
  10283.  
  10284. prior_iv_3:    bclr.b    #3,$0f(a6)
  10285.  
  10286.         IFEQ    Z80_MODE
  10287.         bsr.w    write_d6_stackx
  10288.         ELSE
  10289.         ror.w    #8,d6
  10290.         subq.w    #2,d5
  10291.         move.w    d6,(a2,d5.l)
  10292.         ENDIF
  10293.  
  10294.         lea    $58(a3),a0
  10295.         move.l    a3,z80_pc_base
  10296.         move.b    #1,i_flag
  10297.         clr.b    z80_halt
  10298.         bra.w    no_interrupts_3
  10299.  
  10300. prior_v_3:    bclr.b    #4,$0f(a6)
  10301.  
  10302.         IFEQ    Z80_MODE
  10303.         bsr.w    write_d6_stackx
  10304.         ELSE
  10305.         ror.w    #8,d6
  10306.         subq.w    #2,d5
  10307.         move.w    d6,(a2,d5.l)
  10308.         ENDIF
  10309.  
  10310.         lea    $60(a3),a0
  10311.         move.l    a3,z80_pc_base
  10312.         move.b    #1,i_flag
  10313.         clr.b    z80_halt
  10314.         bra.w    no_interrupts_3
  10315.  
  10316. prior_i_4:    btst.b    #7,$40(a6)            ;lcd on?
  10317.         beq.w    no_interrupts_4            ;no.
  10318.  
  10319.         bclr.b    #0,$0f(a6)
  10320.  
  10321.         IFEQ    Z80_MODE
  10322.         bsr.w    write_d6_stackx
  10323.         ELSE
  10324.         ror.w    #8,d6
  10325.         subq.w    #2,d5
  10326.         move.w    d6,(a2,d5.l)
  10327.         ENDIF
  10328.  
  10329.         lea    $40(a3),a0
  10330.         move.l    a3,z80_pc_base
  10331.         move.b    #1,i_flag
  10332.         clr.b    z80_halt
  10333.         bra.w    no_interrupts_4
  10334.  
  10335.         IFLE    Z80_MODE
  10336. prior_ii_4:    btst.b    #7,$40(a6)            ;lcd on?
  10337.         beq.w    no_interrupts_4            ;no.
  10338.  
  10339.         bclr.b    #1,$0f(a6)
  10340.  
  10341.         IFEQ    Z80_MODE
  10342.         bsr.w    write_d6_stackx
  10343.         ELSE
  10344.         ror.w    #8,d6
  10345.         subq.w    #2,d5
  10346.         move.w    d6,(a2,d5.l)
  10347.         ENDIF
  10348.  
  10349.         lea    $48(a3),a0
  10350.         move.l    a3,z80_pc_base
  10351.         move.b    #1,i_flag
  10352.         clr.b    z80_halt
  10353.         bra.w    no_interrupts_4
  10354.  
  10355. prior_iii_4:    bclr.b    #2,$0f(a6)
  10356.  
  10357.         IFEQ    Z80_MODE
  10358.         bsr.w    write_d6_stackx
  10359.         ELSE
  10360.         ror.w    #8,d6
  10361.         subq.w    #2,d5
  10362.         move.w    d6,(a2,d5.l)
  10363.         ENDIF
  10364.  
  10365.         lea    $50(a3),a0
  10366.         move.l    a3,z80_pc_base
  10367.         move.b    #1,i_flag
  10368.         clr.b    z80_halt
  10369.         bra.w    no_interrupts_4
  10370.         ENDIF
  10371.  
  10372. prior_iv_4:    bclr.b    #3,$0f(a6)
  10373.  
  10374.         IFEQ    Z80_MODE
  10375.         bsr.w    write_d6_stackx
  10376.         ELSE
  10377.         ror.w    #8,d6
  10378.         subq.w    #2,d5
  10379.         move.w    d6,(a2,d5.l)
  10380.         ENDIF
  10381.  
  10382.         lea    $58(a3),a0
  10383.         move.l    a3,z80_pc_base
  10384.         move.b    #1,i_flag
  10385.         clr.b    z80_halt
  10386.         bra.w    no_interrupts_4
  10387.  
  10388. prior_v_4:    bclr.b    #4,$0f(a6)
  10389.  
  10390.         IFEQ    Z80_MODE
  10391.         bsr.w    write_d6_stackx
  10392.         ELSE
  10393.         ror.w    #8,d6
  10394.         subq.w    #2,d5
  10395.         move.w    d6,(a2,d5.l)
  10396.         ENDIF
  10397.  
  10398.         lea    $60(a3),a0
  10399.         move.l    a3,z80_pc_base
  10400.         move.b    #1,i_flag
  10401.         clr.b    z80_halt
  10402.         bra.w    no_interrupts_4
  10403.  
  10404. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10405. ;        lcd interrupt
  10406. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10407.  
  10408. lcd_irq_eh:    tst.b    d6
  10409.         beq.s    lcd_h_blank
  10410.         cmp.b    #1,d6
  10411.         beq.s    lcd_v_blank
  10412.         cmp.b    #2,d6
  10413.         beq.s    lcd_oam
  10414.         rts
  10415.  
  10416. ;lcd_3_blank:    bset.b    #1,$0f(a6)            ;lcd occurred.
  10417. ;        rts
  10418.  
  10419. lcd_h_blank:    btst.b    #3,$41(a6)
  10420.         beq.s    lcd_irq_quit
  10421.         btst.b    #2,irq_status_flags        ;after lyc?
  10422.         bne.s    lcd_irq_quit
  10423.  
  10424.         IFGT    GAMEBOY_DEBUG
  10425.         bsr.w    debug_lcd
  10426.         ENDIF
  10427.  
  10428.         bset.b    #0,irq_status_flags        ;hblank occurred.
  10429.         bset.b    #1,$0f(a6)            ;lcd occurred.
  10430. lcd_irq_quit:    rts
  10431.  
  10432. lcd_v_blank:    btst.b    #4,$41(a6)
  10433.         beq.s    lcd_irq_quit
  10434.  
  10435.         IFGT    GAMEBOY_DEBUG
  10436.         bsr.w    debug_lcd
  10437.         ENDIF
  10438.  
  10439.         bset.b    #1,$0f(a6)            ;lcd occurred.
  10440.         rts
  10441.  
  10442. lcd_oam:    btst.b    #5,$41(a6)
  10443.         beq.s    lcd_irq_quit
  10444.         btst.b    #0,irq_status_flags
  10445.         bne.s    lcd_irq_quit
  10446.         btst.b    #2,irq_status_flags        ;after lyc?
  10447.         bne.s    lcd_irq_quit
  10448.         btst.b    #1,irq_status_flags        ;vbr effect?
  10449.         beq.s    lcd_oam_no_vbr_filtering
  10450.         tst.l    gb_scanlines
  10451.         beq.s    lcd_irq_quit            ;yes, $00 is off limits.
  10452.  
  10453. lcd_oam_no_vbr_filtering:
  10454.  
  10455.         IFGT    GAMEBOY_DEBUG
  10456.         bsr.w    debug_lcd
  10457.         ENDIF
  10458.  
  10459.         bset.b    #1,$0f(a6)            ;lcd occurred.
  10460.         rts
  10461.  
  10462. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10463. ;        next frame - check the buttons and loop
  10464. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10465.  
  10466. next_frame:    bsr.w    push_z80
  10467.  
  10468. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10469. ;        MBC3 clock emulation
  10470. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10471.  
  10472.         tst.b    mbc3_existence
  10473.         beq.s    no_mbc3_clock
  10474.  
  10475.         add.b    #1,mbc3_sec
  10476.         cmp.b    #60,mbc3_sec
  10477.         bne.s    mbc3_clock_done
  10478.  
  10479.         clr.b    mbc3_sec
  10480.         add.b    #1,mbc3_min
  10481.         cmp.b    #60,mbc3_min
  10482.         bne.s    mbc3_clock_done
  10483.  
  10484.         clr.b    mbc3_min
  10485.         add.b    #1,mbc3_hrs
  10486.         cmp.b    #60,mbc3_hrs
  10487.         bne.s    mbc3_clock_done
  10488.  
  10489.         clr.b    mbc3_hrs
  10490.         move.w    mbc3_day,d7
  10491.         addq.w    #1,d7
  10492.         btst    #9,d7
  10493.         beq.s    mbc3_clock_no_day_carry
  10494.         or.w    #%1000000000000000,d7
  10495. mbc3_clock_no_day_carry:
  10496.         and.w    #%1100000111111111,d7
  10497.         move.w    d7,mbc3_day        
  10498.  
  10499. mbc3_clock_done:
  10500. no_mbc3_clock:    and.b    #%10,irq_status_flags        ;clear oam and lyc flag.
  10501.  
  10502.         move.b    output_bit,d7
  10503.         cmp.b    frame_update,d7
  10504.         bne.s    no_empty
  10505.         clr.b    output_bit            ;reset the counter.
  10506.  
  10507. no_empty:    addq.b    #1,output_bit            ;one frame done.
  10508.  
  10509.         cmp.b    #2,snd_quality
  10510.         beq.w    sfx_update_all            ;use y value to update
  10511.                             ;audio data.
  10512. sfx_back:    cmp.b    #INPUT_OK,input_status
  10513.         beq.w    cartridge_loop
  10514.         cmp.b    #INPUT_HALT,input_status
  10515.         beq.w    z80_halted
  10516.         cmp.b    #INPUT_GBS_LOAD,input_status
  10517.         beq.s    input_gbs_load
  10518.  
  10519. input_gbs_save:    bsr.w    runtime_gbs_save
  10520.         clr.b    input_status
  10521.         bra.w    cartridge_loop
  10522.  
  10523. input_gbs_load:    bsr.w    runtime_gbs_load
  10524.         clr.b    input_status
  10525.         bra.w    cartridge_loop
  10526.  
  10527. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10528. ;        execute a timer interrupt if needed
  10529. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10530.  
  10531. irq_timer:    and.l    #%11,d7                ;save the frequency value.
  10532.         lea    freq_table,a5            ;a5 = the value table.
  10533.         move.l    (a5,d7.w*4),d6            ;d6 = the freq*4096/60/154/5.
  10534.         add.l    freq_storage,d6            ;add the old value.
  10535.         move.l    d6,d7                ;store the value.
  10536.         lsr.l    #8,d6
  10537.         lsr.l    #4,d6                ;d6 = updated timer register.
  10538.         cmp.l    #$ff,d6
  10539.         ble.s    write_timer            ;no overflow.
  10540.  
  10541.         moveq.l    #0,d7
  10542.         move.b    $06(a6),d6            ;d6 = timemod (timer modulo).
  10543.         move.b    d6,d7
  10544.         lsl.l    #8,d7
  10545.         lsl.l    #4,d7
  10546.  
  10547.         btst.b    #2,$ff(a6)            ;timer overflow?
  10548.         beq.s    write_timer            ;no. it's disabled. ;(
  10549.  
  10550.         IFGT    GAMEBOY_DEBUG
  10551.         bsr.w    debug_timer
  10552.         ENDIF
  10553.  
  10554. timer_starts:    bset.b    #2,$0f(a6)            ;timer occurred.
  10555. write_timer:    move.b    d6,$05(a6)            ;update timecnt.
  10556.         move.l    d7,freq_storage            ;update fixed storage.
  10557. no_timer_update:rts
  10558.  
  10559. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10560. ;        the aga h/w mode vbr interrupt
  10561. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10562.  
  10563. vbr_interrupt:    movem.l    d0-d7/a0-a6,-(SP)
  10564.  
  10565. load_copper_in:    move.l    copper_inactive,d0
  10566.         tst.b    old_refresh            ;144/144?
  10567.         beq.w    copper_144_144            ;yes.
  10568.  
  10569. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10570. ;        1/144 aga h/w plane pointer loads
  10571. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10572.  
  10573.         cmp.l    copper_I,d0
  10574.         beq.s    xload_copper_II
  10575. xload_copper_I:    move.l    bg_scroll_y_I,d1        ;y scrolling (0-7).
  10576.         clr.b    visual_frame            ;buffer 0 is used.
  10577.         move.l    aga_map_I,d0
  10578.         add.l    #40*8*16,d0            ;background planes.
  10579.         move.w    d1,d2
  10580.         lsl.b    #5,d1
  10581.         lsl.b    #3,d2
  10582.         add.w    d2,d1
  10583.         lsl.w    #3,d1                ;planes (8), too.
  10584.         add.l    d1,d0                ;new y!
  10585.         move.l    aga_pln_cI,a0
  10586.         moveq.l    #4-1,d1
  10587.         moveq.l    #40,d2                ;modulus.
  10588.         bsr.w    load_bitplanes            ;load planes.
  10589.  
  10590.         move.l    aga_map_I,d0
  10591.         add.l    #40*8*16+40*4,d0        ;sprite planes.
  10592.         move.l    aga_pln_cI,a0
  10593.         add.l    #2*4*4,a0            ;to sprite plane pointers.
  10594.         moveq.l    #4-1,d1
  10595.         moveq.l    #40,d2                ;modulus.
  10596.         bsr.w    load_bitplanes            ;load planes.
  10597.  
  10598.         move.l    aga_ro_list_I,a0        ;the shift input list.
  10599.         lea    aga_spr_Ia,a6            ;sprites.
  10600.         bra.w    load_copper_xit
  10601. xload_copper_II:move.l    bg_scroll_y_II,d1        ;y scrolling (0-7).
  10602.         move.b    #1,visual_frame            ;buffer 1 is used.
  10603.         move.l    aga_map_II,d0
  10604.         add.l    #40*8*16,d0            ;background planes.
  10605.         move.w    d1,d2
  10606.         lsl.b    #5,d1
  10607.         lsl.b    #3,d2
  10608.         add.w    d2,d1
  10609.         lsl.w    #3,d1                ;planes (8), too.
  10610.         add.l    d1,d0                ;new y!
  10611.         move.l    aga_pln_cI,a0
  10612.         moveq.l    #8-1,d1
  10613.         moveq.l    #40,d2                ;modulus.
  10614.         bsr.w    load_bitplanes            ;load planes.
  10615.  
  10616.         move.l    aga_map_II,d0
  10617.         add.l    #40*8*16+40*4,d0        ;sprite planes.
  10618.         move.l    aga_pln_cI,a0
  10619.         add.l    #2*4*4,a0            ;to sprite plane pointers.
  10620.         moveq.l    #4-1,d1
  10621.         moveq.l    #40,d2                ;modulus.
  10622.         bsr.w    load_bitplanes            ;load planes.
  10623.  
  10624.         move.l    aga_ro_list_II,a0        ;the shift input list.
  10625.         lea    aga_spr_Ib,a6            ;sprites.
  10626.         bra.w    load_copper_xit
  10627.  
  10628. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10629. ;        144/144 aga h/w plane pointer loads
  10630. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10631.  
  10632. copper_144_144:    cmp.l    copper_I,d0
  10633.         beq.s    load_copper_II
  10634. load_copper_I:    clr.b    visual_frame
  10635.         move.l    aga_map_I,d0
  10636.         move.l    aga_pln_cI,a0
  10637.         moveq.l    #8-1,d1
  10638.         moveq.l    #40,d2                ;modulus.
  10639.         bsr.w    load_bitplanes            ;load planes.
  10640.         move.l    aga_ro_list_I,a0        ;the shift input list.
  10641.         lea    aga_spr_Ia,a6            ;sprites.
  10642.         bra.s    load_copper_xit
  10643. load_copper_II:    move.b    #1,visual_frame
  10644.         move.l    aga_map_II,d0
  10645.         move.l    aga_pln_cI,a0
  10646.         moveq.l    #8-1,d1
  10647.         moveq.l    #40,d2                ;modulus.
  10648.         bsr.w    load_bitplanes            ;load planes.
  10649.         move.l    aga_ro_list_II,a0        ;the shift input list.
  10650.         lea    aga_spr_Ib,a6            ;sprites.
  10651.  
  10652. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10653. ;        copper updating continues
  10654. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10655.  
  10656. load_copper_xit:move.l    aga_scr_0_cI,a1
  10657.         move.l    aga_scr_cI,a2
  10658.         move.b    (a0)+,3(a1)            ;the first value.
  10659.  
  10660.         tst.b    old_refresh            ;144/144?
  10661.         bne.s    no_more_shifts            ;nope.
  10662.  
  10663.         move.w    #144-1-1,d0
  10664.         addq.l    #2+2+2+1,a2
  10665. load_roller_vs:    move.b    (a0)+,(a2)            ;new scroll values.
  10666.         addq.l    #8,a2                ;next value.
  10667.         dbra    d0,load_roller_vs        ;          .
  10668.  
  10669. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10670. ;        load sprite pointers
  10671. ;        INPUT:
  10672. ;        a6    = pointer to sprite pointer list.
  10673. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10674.  
  10675. no_more_shifts:    moveq.l    #3-1,d0
  10676.         move.l    aga_spr_cI,a0            ;output.
  10677.         lea    aga_spr_Ix,a1            ;mask sprites.
  10678. load_hw_window:    move.l    (a6)+,a2
  10679.         move.l    (a1)+,a3
  10680.         move.w    (a2),(a3)            ;copy position data.
  10681.         move.w    8(a2),8(a3)
  10682.         move.l    a2,d1
  10683.         move.w    d1,6(a0)
  10684.         swap    d1
  10685.         move.w    d1,2(a0)
  10686.         addq.l    #8,a0
  10687.         dbra    d0,load_hw_window        ;next sprite.
  10688.  
  10689.         movem.l    (SP)+,d0-d7/a0-a6
  10690.         jmp    ([old_vbr])            ;jump to the system routine.
  10691.  
  10692. ;        move.w    #$60,intreq+$dff000
  10693. ;        rte
  10694.  
  10695. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10696. ;        z80 processor halted
  10697. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10698.  
  10699. z80_halted:    tst.b    old_render
  10700.         bne.s    no_aga_exit            ;no aga mode used.
  10701.  
  10702.         move.l    vbr_pointer,a0            ;return the old
  10703.         move.l    old_vbr,$6c(a0)            ;interrupt.
  10704.  
  10705.         move.l    graphics_base,a6
  10706.         move.l    old_wb_view,a1
  10707.         jsr    LoadView(a6)            ;fix the view.
  10708.         jsr    WaitTOF(a6)
  10709.         jsr    WaitTOF(a6)            ;wait for LoadView().
  10710.         move.l    old_copper,cop1lc+$dff000
  10711.         move.w    old_dmareq,d0
  10712.         or.w    #$8000,d0
  10713.         move.w    d0,dmacon+$dff000
  10714.  
  10715. no_aga_exit:    tst.b    forbid_permit_status
  10716.         bne.s    no_permit
  10717.  
  10718.         move.l    exec_base,a6
  10719.         jsr    Permit(a6)
  10720.  
  10721. no_permit:    tst.l    block_screen_ptr
  10722.         beq.s    no_block_screen_exit
  10723.  
  10724.         move.l    intuition_base,a6
  10725.         move.l    block_screen_ptr,d0
  10726.         beq.s    no_aga_exit
  10727.         move.l    d0,a0
  10728.         jsr    CloseScreen(a6)
  10729.         clr.l    block_screen_ptr
  10730.  
  10731. no_block_screen_exit:
  10732.         rts                    ;exit the cartridge runner.
  10733.  
  10734. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10735. ;        do the joystick input. or is it the keyboard input?
  10736. ;        or what the hell is it!? ;)
  10737. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10738.  
  10739. inputs_read:    lea    joy_item_list,a0
  10740.         moveq.l    #0,d0
  10741.         move.b    keystick,d0
  10742.         move.b    (a0,d0.l),d1            ;which one to use?
  10743.         beq.s    input_keyboard            ;keyboard.
  10744.         cmp.b    #1,d1
  10745.         beq.w    input_joypad            ;cd³² joypad.
  10746.         cmp.b    #2,d1
  10747.         beq.w    input_sega_4b            ;sega 4 button joypad.
  10748.         cmp.b    #3,d1
  10749.         beq.w    input_sega_2b            ;sega 2 button joypad.
  10750.         cmp.b    #4,d1
  10751.         beq.w    input_joystick_1b        ;joystick.
  10752.         cmp.b    #5,d1
  10753.         beq.w    input_joystick_2b        ;joystick.
  10754.  
  10755.         move.b    #INPUT_HALT,input_status    ;pause!!!!!
  10756.         rts
  10757.  
  10758. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10759. ;        keyboard input selected. read the keyboard
  10760. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10761.  
  10762. input_keyboard:    move.l    exec_base,a6
  10763.         move.l    keyboard_io,a1
  10764.         jsr    SendIO(a6)
  10765.  
  10766.         move.b    #$ff,d0
  10767.         move.b    #$ff,d1
  10768.         move.l    keyboard_matrix,a1
  10769.         btst.b    #1,3(a1)            ;p?
  10770.         bne.w    paused_gb
  10771.         btst.b    #5,8(a1)            ;esc?
  10772.         bne.w    paused_gb
  10773.  
  10774.         tst.b    10(a1)
  10775.         bne.s    gbs_byte_10
  10776.         btst.b    #0,11(a1)            ;f9?
  10777.         bne.w    gbs_load_4
  10778.         btst.b    #1,11(a1)            ;f10?
  10779.         bne.w    gbs_load_5
  10780.  
  10781.         move.b    9(a1),d2
  10782.  
  10783.         btst    #4,d2                ;up?
  10784.         beq.s    no_up_key_rd
  10785.         bclr    #2,d0
  10786. no_up_key_rd:    btst    #5,d2                ;down?
  10787.         beq.s    no_down_key_rd
  10788.         bclr    #3,d0
  10789. no_down_key_rd:    btst    #6,d2                ;right?
  10790.         beq.s    no_righ_key_rd
  10791.         bclr    #0,d0
  10792. no_righ_key_rd:    btst    #7,d2                ;left?
  10793.         beq.s    no_left_key_rd
  10794.         bclr    #1,d0
  10795.  
  10796. no_left_key_rd:    move.b    12(a1),d2
  10797.  
  10798.         btst    #0,d2                ;b (left shift)?
  10799.         beq.s    no_left_shf_rd
  10800.         bclr    #1,d1
  10801. no_left_shf_rd:    btst    #4,d2                ;a (left alt)?
  10802.         beq.s    no_left_alt_rd
  10803.         bclr    #0,d1
  10804. no_left_alt_rd:    btst    #1,d2                ;start (right shift)?
  10805.         beq.s    no_righ_shf_rd
  10806.         bclr    #3,d1
  10807. no_righ_shf_rd:    btst    #5,d2                ;select (right alt)?
  10808.         beq.s    no_righ_alt_rd
  10809.         bclr    #2,d1
  10810.  
  10811. no_righ_alt_rd:    move.b    d0,directions_byte
  10812.         move.b    d1,buttons_byte
  10813. rd_keyb_exit:    move.b    #INPUT_OK,input_status        ;no pause.
  10814.         rts
  10815.  
  10816. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10817. ;        gbs save and load routines
  10818. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10819.  
  10820. gbs_byte_10:    btst.b    #0,10(a1)            ;f1?
  10821.         bne.w    gbs_save_1
  10822.         btst.b    #1,10(a1)            ;f2?
  10823.         bne.w    gbs_save_2
  10824.         btst.b    #2,10(a1)            ;f3?
  10825.         bne.w    gbs_save_3
  10826.         btst.b    #3,10(a1)            ;f4?
  10827.         bne.w    gbs_save_4
  10828.         btst.b    #4,10(a1)            ;f5?
  10829.         bne.w    gbs_save_5
  10830.  
  10831.         btst.b    #5,10(a1)            ;f6?
  10832.         bne.w    gbs_load_1
  10833.         btst.b    #6,10(a1)            ;f7?
  10834.         bne.w    gbs_load_2
  10835.         bra.w    gbs_load_3
  10836.  
  10837. gbs_operation:    cmp.b    #$50,d1                ;f1?
  10838.         beq.w    gbs_save_1
  10839.         cmp.b    #$51,d1                ;f2?
  10840.         beq.w    gbs_save_2
  10841.         cmp.b    #$52,d1                ;f3?
  10842.         beq.w    gbs_save_3
  10843.         cmp.b    #$53,d1                ;f4?
  10844.         beq.w    gbs_save_4
  10845.         cmp.b    #$54,d1                ;f5?
  10846.         beq.w    gbs_save_5
  10847.  
  10848.         cmp.b    #$55,d1                ;f6?
  10849.         beq.w    gbs_load_1
  10850.         cmp.b    #$56,d1                ;f7?
  10851.         beq.w    gbs_load_2
  10852.         cmp.b    #$57,d1                ;f8?
  10853.         beq.w    gbs_load_3
  10854.         cmp.b    #$58,d1                ;f9?
  10855.         beq.w    gbs_load_4
  10856.         bra.w    gbs_load_5
  10857.  
  10858. gbs_save_1:    move.b    #"1",gbs_file_id
  10859.         move.b    #INPUT_GBS_SAVE,input_status
  10860.         rts
  10861. gbs_save_2:    move.b    #"2",gbs_file_id
  10862.         move.b    #INPUT_GBS_SAVE,input_status
  10863.         rts
  10864. gbs_save_3:    move.b    #"3",gbs_file_id
  10865.         move.b    #INPUT_GBS_SAVE,input_status
  10866.         rts
  10867. gbs_save_4:    move.b    #"4",gbs_file_id
  10868.         move.b    #INPUT_GBS_SAVE,input_status
  10869.         rts
  10870. gbs_save_5:    move.b    #"5",gbs_file_id
  10871.         move.b    #INPUT_GBS_SAVE,input_status
  10872.         rts
  10873.  
  10874. gbs_load_1:    move.b    #"1",gbs_file_id
  10875.         move.b    #INPUT_GBS_LOAD,input_status
  10876.         rts
  10877. gbs_load_2:    move.b    #"2",gbs_file_id
  10878.         move.b    #INPUT_GBS_LOAD,input_status
  10879.         rts
  10880. gbs_load_3:    move.b    #"3",gbs_file_id
  10881.         move.b    #INPUT_GBS_LOAD,input_status
  10882.         rts
  10883. gbs_load_4:    move.b    #"4",gbs_file_id
  10884.         move.b    #INPUT_GBS_LOAD,input_status
  10885.         rts
  10886. gbs_load_5:    move.b    #"5",gbs_file_id
  10887.         move.b    #INPUT_GBS_LOAD,input_status
  10888.         rts
  10889.  
  10890. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10891. ;        read from the cd³² joypad
  10892. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10893.  
  10894. input_joypad:
  10895.  
  10896.         move.l    low_level_base,a6
  10897.         moveq.l    #1,d0
  10898.         jsr    ReadJoyPort(a6)
  10899.  
  10900.         btst    #JPB_BUTTON_PLAY,d0        ;paused?
  10901.         bne.w    paused_gb
  10902.  
  10903.         btst    #JPB_BUTTON_REVERSE,d0
  10904.         bne.w    gbs_save_1
  10905.         btst    #JPB_BUTTON_FORWARD,d0
  10906.         bne.w    gbs_load_1
  10907.  
  10908.         moveq.l    #0,d1
  10909.         move.b    $bfec01,d1            ;get p-key from keyboard.
  10910.         not.b    d1
  10911.         ror.b    #1,d1
  10912.  
  10913.         cmp.l    #$50,d1
  10914.         blt.s    no_gbs_op_joypad
  10915.         cmp.l    #$59,d1
  10916.         ble.w    gbs_operation
  10917.  
  10918. no_gbs_op_joypad:
  10919.         move.b    #$ff,d1                ;directions byte.
  10920.         move.b    #$ff,d2                ;buttons byte.
  10921.  
  10922.         btst    #JPB_JOY_UP,d0
  10923.         beq.s    no_up
  10924.         bclr    #2,d1                ;up set. ;)
  10925. no_up:        btst    #JPB_JOY_DOWN,d0
  10926.         beq.s    no_down
  10927.         bclr    #3,d1                ;down set.
  10928. no_down:    btst    #JPB_JOY_LEFT,d0
  10929.         beq.s    no_left
  10930.         bclr    #1,d1                ;left set.
  10931. no_left:    btst    #JPB_JOY_RIGHT,d0
  10932.         beq.s    no_right
  10933.         bclr    #0,d1                ;right set.
  10934.  
  10935. no_right:    btst    #JPB_BUTTON_RED,d0
  10936.         beq.s    no_red
  10937.         bclr    #1,d2                ;red / b set.
  10938. no_red:        btst    #JPB_BUTTON_BLUE,d0
  10939.         beq.s    no_blue
  10940.         bclr    #0,d2                ;blue / a set.
  10941. no_blue:    btst    #JPB_BUTTON_GREEN,d0
  10942.         beq.s    no_green
  10943.         bclr    #2,d2                ;green / select set.
  10944. no_green:    btst    #JPB_BUTTON_YELLOW,d0
  10945.         beq.s    no_yellow
  10946.         bclr    #3,d2                ;yellow / start set.
  10947.  
  10948. no_yellow:    move.b    d1,directions_byte        ;output the capture.
  10949.         move.b    d2,buttons_byte
  10950.  
  10951.         move.b    #INPUT_OK,input_status        ;no pause
  10952.         rts
  10953.  
  10954. paused_gb:    cmp.b    #1,old_render            ;screen mode?
  10955.         bne.s    no_front_gb            ;nope.
  10956.  
  10957.         move.l    gb_screen_ptr,a0
  10958.         move.l    intuition_base,a6
  10959.         jsr    ScreenToBack(a6)        ;screen to back.
  10960.  
  10961. no_front_gb:    move.b    #INPUT_HALT,input_status    ;emulator paused.
  10962.         rts
  10963.  
  10964. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10965. ;        read input signals from a four button sega joypad
  10966. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10967.  
  10968. input_sega_4b:
  10969.  
  10970.         move.l    control_pad_base,a6
  10971.         move.b    #CPU_JOYPORT,d0            ;the unit.
  10972.         move.l    cp_handle,a0
  10973.         jsr    cpGet(a6)            ;get sega pad info.
  10974.  
  10975.         move.b    $bfec01,d1            ;get p-key from keyboard.
  10976.         not.b    d1
  10977.         ror.b    #1,d1
  10978.  
  10979.         cmp.b    #$19,d1                ;p?
  10980.         beq.s    paused_gb            ;yes.
  10981.         cmp.b    #$45,d1                ;esc?
  10982.         beq.s    paused_gb            ;yes.
  10983.  
  10984.         cmp.l    #$50,d1
  10985.         blt.s    no_gbs_op_sega_4b
  10986.         cmp.l    #$59,d1
  10987.         ble.w    gbs_operation
  10988.  
  10989. no_gbs_op_sega_4b:
  10990.  
  10991. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10992. ;        INPUT:
  10993. ;        d0    = joypad_data.W.
  10994. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  10995.  
  10996.         move.b    #$ff,d1                ;directions byte.
  10997.         move.b    #$ff,d2                ;buttons byte.
  10998.  
  10999.         btst    #CPB_UP,d0
  11000.         beq.s    no_cpb_up
  11001.         bclr    #2,d1                ;up set. ;)
  11002. no_cpb_up:    btst    #CPB_DOWN,d0
  11003.         beq.s    no_cpb_down
  11004.         bclr    #3,d1                ;down set.
  11005. no_cpb_down:    btst    #CPB_LEFT,d0
  11006.         beq.s    no_cpb_left
  11007.         bclr    #1,d1                ;left set.
  11008. no_cpb_left:    btst    #CPB_RIGHT,d0
  11009.         beq.s    no_cpb_right
  11010.         bclr    #0,d1                ;right set.
  11011.  
  11012. no_cpb_right:    btst    #CPB_B,d0
  11013.         beq.s    no_cpb_b
  11014.         bclr    #1,d2                ;b / b set.
  11015. no_cpb_b:    btst    #CPB_A,d0
  11016.         beq.s    no_cpb_a
  11017.         bclr    #0,d2                ;a / a set.
  11018. no_cpb_a:    btst    #CPB_C,d0
  11019.         beq.s    no_cpb_c
  11020.         bclr    #2,d2                ;c / select set.
  11021. no_cpb_c:    btst    #CPB_START,d0
  11022.         beq.s    no_cpb_start
  11023.         bclr    #3,d2                ;start / start set.
  11024.  
  11025. no_cpb_start:    move.b    d1,directions_byte        ;output the capture.
  11026.         move.b    d2,buttons_byte
  11027.  
  11028.         move.b    #INPUT_OK,input_status        ;no pause
  11029.         rts
  11030.  
  11031. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11032. ;        read inputs from a two buttons sega joypad and
  11033. ;        the keyboard device
  11034. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11035.  
  11036. input_sega_2b:
  11037.  
  11038.         move.l    exec_base,a6
  11039.         move.l    keyboard_io,a1
  11040.         jsr    SendIO(a6)
  11041.  
  11042.         move.l    keyboard_matrix,a1
  11043.         btst.b    #1,3(a1)            ;p?
  11044.         bne.w    paused_gb
  11045.         btst.b    #5,8(a1)            ;esc?
  11046.         bne.w    paused_gb
  11047.  
  11048.         tst.b    10(a1)
  11049.         bne.w    gbs_byte_10
  11050.         btst.b    #0,11(a1)            ;f9?
  11051.         bne.w    gbs_load_4
  11052.         btst.b    #1,11(a1)            ;f10?
  11053.         bne.w    gbs_load_5
  11054.  
  11055.         move.l    control_pad_base,a6
  11056.         move.b    #CPU_JOYPORT,d0            ;the unit.
  11057.         move.l    cp_handle,a0
  11058.         jsr    cpGet(a6)            ;get sega pad info.
  11059.  
  11060. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11061. ;        INPUT:
  11062. ;        d0    = joypad_data.W.
  11063. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11064.  
  11065.         move.b    #$ff,d1                ;directions byte.
  11066.         move.b    #$ff,d2                ;buttons byte.
  11067.  
  11068.         btst    #CPB_UP,d0
  11069.         beq.s    no_cpbx_up
  11070.         bclr    #2,d1                ;up set. ;)
  11071. no_cpbx_up:    btst    #CPB_DOWN,d0
  11072.         beq.s    no_cpbx_down
  11073.         bclr    #3,d1                ;down set.
  11074. no_cpbx_down:    btst    #CPB_LEFT,d0
  11075.         beq.s    no_cpbx_left
  11076.         bclr    #1,d1                ;left set.
  11077. no_cpbx_left:    btst    #CPB_RIGHT,d0
  11078.         beq.s    no_cpbx_right
  11079.         bclr    #0,d1                ;right set.
  11080.  
  11081. no_cpbx_right:    btst    #CPB_C,d0
  11082.         beq.s    no_cpbx_cx
  11083.         bclr    #0,d2                ;c / a set.
  11084. no_cpbx_cx:    btst    #CPB_B,d0
  11085.         beq.s    no_cpbx_bx
  11086.         bclr    #1,d2                ;b / b set.
  11087.  
  11088. no_cpbx_bx:    move.l    keyboard_matrix,a1
  11089.         move.b    12(a1),d3
  11090.  
  11091.         btst    #0,d3                ;b (left shift)?
  11092.         beq.s    no_left_shf_sg
  11093.         bclr    #1,d2
  11094. no_left_shf_sg:    btst    #4,d3                ;a (left alt)?
  11095.         beq.s    no_left_alt_sg
  11096.         bclr    #0,d2
  11097. no_left_alt_sg:    btst    #1,d3                ;start (right shift)?
  11098.         beq.s    no_righ_shf_sg
  11099.         bclr    #3,d2
  11100. no_righ_shf_sg:    btst    #5,d3                ;select (right alt)?
  11101.         beq.s    no_righ_alt_sg
  11102.         bclr    #2,d2
  11103.  
  11104. no_righ_alt_sg:    move.b    d1,directions_byte
  11105.         move.b    d2,buttons_byte
  11106.  
  11107. sg_keyb_exit:    move.b    #INPUT_OK,input_status        ;no pause.
  11108.         rts
  11109.  
  11110. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11111. ;        read inputs from the 1b joystick and keyboard
  11112. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11113.  
  11114. input_joystick_1b:
  11115.         move.l    exec_base,a6
  11116.         move.l    keyboard_io,a1
  11117.         jsr    SendIO(a6)
  11118.  
  11119.         move.b    #$ff,d0
  11120.         move.b    #$ff,d1
  11121.         move.l    keyboard_matrix,a1
  11122.         btst.b    #1,3(a1)            ;p?
  11123.         bne.w    paused_gb
  11124.         btst.b    #5,8(a1)            ;esc?
  11125.         bne.w    paused_gb
  11126.  
  11127.         tst.b    10(a1)
  11128.         bne.w    gbs_byte_10
  11129.         btst.b    #0,11(a1)            ;f9?
  11130.         bne.w    gbs_load_4
  11131.         btst.b    #1,11(a1)            ;f10?
  11132.         bne.w    gbs_load_5
  11133.  
  11134.         move.b    12(a1),d3
  11135.  
  11136.         btst    #0,d3                ;b (left shift)?
  11137.         beq.s    no_left_shf_js
  11138.         bclr    #1,d1
  11139. no_left_shf_js:    btst    #4,d3                ;a (left alt)?
  11140.         beq.s    no_left_alt_js
  11141.         bclr    #0,d1
  11142. no_left_alt_js:    btst    #1,d3                ;start (right shift)?
  11143.         beq.s    no_righ_shf_js
  11144.         bclr    #3,d1
  11145. no_righ_shf_js:    btst    #5,d3                ;select (right alt)?
  11146.         beq.s    no_righ_alt_js
  11147.         bclr    #2,d1
  11148.  
  11149. no_righ_alt_js:    btst.b    #7,$bfe001
  11150.         bne.s    no_fire_btn_js
  11151.         bclr    #0,d1                ;a (fire button)!
  11152.  
  11153. no_fire_btn_js:    move.w    joy1dat+$dff000,d2
  11154.         move.w    d2,d3
  11155.  
  11156.         btst    #1,d2
  11157.         beq.s    no_right_js
  11158.         bclr    #0,d0
  11159. no_right_js:    btst    #9,d2
  11160.         beq.s    no_left_js
  11161.         bclr    #1,d0
  11162.  
  11163. no_left_js:    ror.w    #1,d3
  11164.         eor.w    d3,d2
  11165.         btst    #0,d2
  11166.         beq.s    no_down_js
  11167.         bclr    #3,d0
  11168. no_down_js:    btst    #8,d2
  11169.         beq.s    no_up_js
  11170.         bclr    #2,d0
  11171.  
  11172. no_up_js:    move.b    d0,directions_byte
  11173.         move.b    d1,buttons_byte
  11174. js_keyb_exit:    move.b    #INPUT_OK,input_status        ;no pause.
  11175.         rts
  11176.  
  11177. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11178. ;        read inputs from the 2b joystick and keyboard
  11179. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11180.  
  11181. input_joystick_2b:
  11182.  
  11183.         move.l    exec_base,a6
  11184.         move.l    keyboard_io,a1
  11185.         jsr    SendIO(a6)
  11186.  
  11187.         move.b    #$ff,d0
  11188.         move.b    #$ff,d1
  11189.         move.l    keyboard_matrix,a1
  11190.         btst.b    #1,3(a1)            ;p?
  11191.         bne.w    paused_gb
  11192.         btst.b    #5,8(a1)            ;esc?
  11193.         bne.w    paused_gb
  11194.  
  11195.         tst.b    10(a1)
  11196.         bne.w    gbs_byte_10
  11197.         btst.b    #0,11(a1)            ;f9?
  11198.         bne.w    gbs_load_4
  11199.         btst.b    #1,11(a1)            ;f10?
  11200.         bne.w    gbs_load_5
  11201.  
  11202.         move.b    12(a1),d3
  11203.  
  11204.         btst    #0,d3                ;b (left shift)?
  11205.         beq.s    zno_left_shf_js
  11206.         bclr    #1,d1
  11207. zno_left_shf_js:btst    #4,d3                ;a (left alt)?
  11208.         beq.s    zno_left_alt_js
  11209.         bclr    #0,d1
  11210. zno_left_alt_js:btst    #1,d3                ;start (right shift)?
  11211.         beq.s    zno_righ_shf_js
  11212.         bclr    #3,d1
  11213. zno_righ_shf_js:btst    #5,d3                ;select (right alt)?
  11214.         beq.s    zno_righ_alt_js
  11215.         bclr    #2,d1
  11216.  
  11217. zno_righ_alt_js:btst.b    #7,$bfe001
  11218.         bne.s    zno_fire_1btn_js
  11219.         bclr    #0,d1                ;a (fire button 1)!
  11220.  
  11221. zno_fire_1btn_js:
  11222.         move.w    #$FF00,$DFF034
  11223.         nop
  11224.         nop
  11225.         btst.b    #6,$DFF016
  11226.         bne.s   zno_fire_2btn_js
  11227.         bclr    #1,d1                ;b (fire button 2)!
  11228.  
  11229. zno_fire_2btn_js:
  11230.         move.w    joy1dat+$dff000,d2
  11231.         move.w    d2,d3
  11232.  
  11233.         btst    #1,d2
  11234.         beq.s    zno_right_js
  11235.         bclr    #0,d0
  11236. zno_right_js:    btst    #9,d2
  11237.         beq.s    zno_left_js
  11238.         bclr    #1,d0
  11239.  
  11240. zno_left_js:    ror.w    #1,d3
  11241.         eor.w    d3,d2
  11242.         btst    #0,d2
  11243.         beq.s    zno_down_js
  11244.         bclr    #3,d0
  11245. zno_down_js:    btst    #8,d2
  11246.         beq.s    zno_up_js
  11247.         bclr    #2,d0
  11248.  
  11249. zno_up_js:    move.b    d0,directions_byte
  11250.         move.b    d1,buttons_byte
  11251.  
  11252. zjs_keyb_exit:    move.b    #INPUT_OK,input_status        ;no pause.
  11253.         rts
  11254.  
  11255. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11256. ;        push and pull
  11257. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11258.  
  11259.         cnop    0,4
  11260. push_z80:    lea    z80_registers,a6
  11261.         move.l    a0,(a6)+
  11262.         move.l    a1,(a6)+
  11263.         move.l    a2,(a6)+
  11264.         move.l    a3,(a6)+
  11265.         move.l    a4,(a6)+
  11266.         move.l    d0,(a6)+
  11267.         move.l    d1,(a6)+
  11268.         move.l    d2,(a6)+
  11269.         move.l    d3,(a6)+
  11270.         move.l    d4,(a6)+
  11271.         move.l    d5,(a6)
  11272.         rts
  11273.  
  11274.         cnop    0,4
  11275. pull_z80:    lea    z80_registers,a6
  11276.         move.l    (a6)+,a0
  11277.         move.l    (a6)+,a1
  11278.         move.l    (a6)+,a2
  11279.         move.l    (a6)+,a3
  11280.         move.l    (a6)+,a4
  11281.         move.l    (a6)+,d0
  11282.         move.l    (a6)+,d1
  11283.         move.l    (a6)+,d2
  11284.         move.l    (a6)+,d3
  11285.         move.l    (a6)+,d4
  11286.         move.l    (a6),d5
  11287.         rts
  11288.  
  11289. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11290. ;        misc routines
  11291. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11292.  
  11293.         include    "sound_routines.s"
  11294.         include    "routines/list_alloc_32bit.s"
  11295.         include    "routines/load!bitplanes.s"
  11296.         include    "rle_unpacker.s"
  11297.         include    "screen_draw_new_II.s"
  11298.         include    "aga_screen_draw.s"
  11299.         include    "scanline_draw_II.s"
  11300.         include    "scanline_aga_I.s"
  11301.  
  11302.         include    "z80_misc.s"
  11303.  
  11304.         IFEQ    Z80_MODE
  11305.         include    "z80_full_III.s"
  11306.         ELSE
  11307.         include    "z80_crippled_I.s"
  11308.         ENDIF
  11309.  
  11310. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11311. ;        section    murrr,data
  11312. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11313.  
  11314. intuition_name:    dc.b    "intuition.library",0
  11315.         even
  11316. dos_name:    dc.b    "dos.library",0
  11317.         even
  11318. graphics_name:    dc.b    "graphics.library",0
  11319.         even
  11320. disk_font_name:    dc.b    "diskfont.library",0
  11321.         even
  11322. low_level_name:    dc.b    "lowlevel.library",0
  11323.         even
  11324. control_pad_name:
  11325.         dc.b    "controlpad.library",0
  11326.         even
  11327. req_tools_name:    dc.b    "reqtools.library",0
  11328.         even
  11329. gad_tools_name:    dc.b    "gadtools.library",0
  11330.         even
  11331. xpk_master_name:dc.b    "xpkmaster.library",0
  11332.         even
  11333. keyboard_device_name:
  11334.         dc.b    "keyboard.device",0
  11335.         even
  11336. cyber_name:    dc.b    "cybergraphics.library",0
  11337.         even
  11338.  
  11339. exec_base:    dc.l    0
  11340. intuition_base:    dc.l    0
  11341. graphics_base:    dc.l    0
  11342. dos_base:    dc.l    0
  11343. disk_font_base:    dc.l    0
  11344. low_level_base:    dc.l    0
  11345. control_pad_base:
  11346.         dc.l    0
  11347. req_tools_base:    dc.l    0
  11348. gad_tools_base:    dc.l    0
  11349. xpk_master_base:dc.l    0
  11350. cyber_base:    dc.l    0
  11351.  
  11352. cyber_tmp_read_bitmap:
  11353.         dc.l    0
  11354.  
  11355. output_cyber_status:
  11356.         dc.l    0
  11357.  
  11358. cli_load:    dc.l    0
  11359. new_load:    dc.l    0                ;0 = old rom / 1 = fresh rom.
  11360. battery_load:    dc.l    0
  11361.  
  11362. file_length:    dc.l    0
  11363. file_hd:    dc.l    0
  11364. file_info_ptr:    dc.l    0
  11365. file_data_ptr:    dc.l    0
  11366.  
  11367. cartridge_data_length:
  11368.         dc.l    0
  11369.  
  11370. pub_screen_lock:dc.l    0
  11371. visual_info:    dc.l    0
  11372. screen_font_y:    dc.l    0
  11373.  
  11374. aga_status:    dc.l    0
  11375. function_status:dc.l    0
  11376. function_gad:    dc.l    0
  11377. function_jmp:    dc.l    0
  11378.  
  11379. old_copper:    dc.l    0
  11380. old_vbr:    dc.l    0
  11381. old_dmareq:    dc.l    0
  11382. old_wb_view:    dc.l    0
  11383. vbr_pointer:    dc.l    0
  11384.  
  11385. univ_gadget:    dc.l    0
  11386. dimension_info:    dc.l    0
  11387. display_info_handle:
  11388.         dc.l    0
  11389.  
  11390. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11391. ;        font
  11392. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11393.  
  11394. font_ptr:    dc.l    0
  11395.  
  11396. font_attr:    dc.l    font_name
  11397.         dc.w    8                ;y.
  11398.         dc.b    0                ;style.
  11399. font_attr_flags:dc.b    32                ;flags (32 = proportional).
  11400.  
  11401. font_name:    dc.b    "wzonka.font",0
  11402.         even
  11403. another_name:    dc.b    "zapot.font",0
  11404.         even
  11405. res_font_name:    dc.b    "topaz.font",0
  11406.         even
  11407.  
  11408. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11409. ;        xpk master library variables
  11410. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11411.  
  11412. xfh_pointer:    dc.l    0
  11413.  
  11414. xpk_in_tags:    dc.l    XPK_InName,0            ;use the parsed name.
  11415.         dc.l    TAG_END,0
  11416.  
  11417. xpk_unp_tags:    dc.l    XPK_InFH,0            ;file hd.
  11418.         dc.l    XPK_OutBuf,0            ;output buffer.
  11419.         dc.l    XPK_OutBufLen,0            ;output buffer length.
  11420.         dc.l    TAG_END,0
  11421.  
  11422. xpk_pck_tags:    dc.l    XPK_OutFH,0            ;file hd.
  11423.         dc.l    XPK_InBuf,0            ;input buffer.
  11424.         dc.l    XPK_InLen,0            ;input buffer length.
  11425.         dc.l    XPK_PackMethod,pck_method    ;pack method.
  11426.         dc.l    TAG_END,0
  11427.  
  11428. pck_method:    dc.l    "XXXX"                ;the method.
  11429.         dc.b    "."
  11430.         dc.b    100                ;effiency.
  11431.         dc.l    0
  11432.  
  11433. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11434. ;        the xpk sub libraries name finder
  11435. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11436.  
  11437. xpk_names:    dc.l    0
  11438. xpk_names_v:    dc.l    0
  11439. xpk_names_all:    dc.l    0
  11440. xpk_names_list:    dc.l    0
  11441. xpk_dir_name:    dc.b    "LIBS:compressors",0
  11442.         even
  11443.  
  11444. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11445. ;        the req tools requester tag items and variables
  11446. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11447.  
  11448. rt_list:    dc.l    request_ptr_lo
  11449.         dc.l    request_ptr_ss
  11450.         dc.l    request_ptr_get_1
  11451.         dc.l    request_ptr_get_2
  11452.         dc.l    request_ptr_get_3
  11453.         dc.l    request_ptr_get_4
  11454.         dc.l    0
  11455.  
  11456. request_ptr_lo:    dc.l    0                ;loading requester.
  11457. request_ptr_ss:    dc.l    0                ;snapshot saving requester.
  11458. request_ptr_sm:    dc.l    0                ;screenmode requester.
  11459. request_ptr_get_1:
  11460.         dc.l    0                ;a request for directory gets.
  11461. request_ptr_get_2:
  11462.         dc.l    0                ;a request for directory gets.
  11463. request_ptr_get_3:
  11464.         dc.l    0                ;a request for directory gets.
  11465. request_ptr_get_4:
  11466.         dc.l    0                ;a request for directory gets.
  11467. dir_n_name_ptr:    dc.l    0
  11468. def_ss_dir:    dc.l    0
  11469. name_ptr:    dc.l    0
  11470. def_dir:    dc.l    0
  11471.  
  11472. request_load:    dc.b    "Select a cartridge",0
  11473.         even
  11474. request_lsshot:    dc.b    "Load a GBS snapshot",0
  11475.         even
  11476. request_ssshot:    dc.b    "Save a GBS snapshot",0
  11477.         even
  11478. request_get_dir:dc.b    "Select a directory",0
  11479.         even
  11480. request_smode:    dc.b    "Select a screenmode",0
  11481.         even
  11482.  
  11483. req_tags:    dc.l    RT_Window,0
  11484.         dc.l    RTFI_Flags,FREQF_PATGAD
  11485.         dc.l    TAG_END,0
  11486.  
  11487. req_get_dir_tag:dc.l    RT_Window,0
  11488.         dc.l    RTFI_Flags,FREQF_NOFILES
  11489.         dc.l    TAG_END,0
  11490.  
  11491. req_change_tags:dc.l    RTFI_Dir,0
  11492.         dc.l    TAG_END,0
  11493.  
  11494. req_smode_tags:    dc.l    TAG_END,0
  11495.  
  11496. req_change_screen_mode_tags:
  11497.         dc.l    RTSC_DisplayID,0
  11498.         dc.l    TAG_END,0
  11499.  
  11500. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11501. ;        controller
  11502. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11503.  
  11504. input_status:    dc.b    0
  11505. gbs_file_id:    dc.b    0
  11506.         even
  11507.  
  11508. joy_name_1:    dc.b    "KEYBOARD",0
  11509.         even
  11510. joy_name_2:    dc.b    "CD32 PAD",0
  11511.         even
  11512. joy_name_3:    dc.b    "SEGA 4B",0
  11513.         even
  11514. joy_name_4:    dc.b    "SEGA 2B",0
  11515.         even
  11516. joy_name_5:    dc.b    "JOY 1B",0
  11517.         even
  11518. joy_name_6:    dc.b    "JOY 2B",0
  11519.         even
  11520.  
  11521. joy_item_list:    dc.b    0                ;controller id's.
  11522.         dc.b    1
  11523.         dc.b    2
  11524.         dc.b    3
  11525.         dc.b    4
  11526.         dc.b    5
  11527.         even
  11528.  
  11529. cp_handle:    dc.l    0
  11530. keyboard_io:    dc.l    0
  11531. keyboard_matrix:dc.l    0
  11532.  
  11533. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11534. ;        variables for z80_x.S
  11535. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11536.  
  11537. z80_cycles:    dc.l    22;92;456/5
  11538.  
  11539. gb_memory:    dc.l    0
  11540. bank_address:    dc.l    0
  11541. ram_bank_no:    dc.l    0
  11542. ram_banks:    dc.l    0
  11543. ram_banks_mask:    dc.l    0
  11544. rom_banks_mask:    dc.l    0
  11545.  
  11546. memory_banks:    dc.l    0
  11547. z80_pc_base:    dc.l    0
  11548.  
  11549. i_flag:        dc.b    0                ;interrupt flag.
  11550. z80_halt:    dc.b    0                ;halted cpu flag.
  11551.         even
  11552.  
  11553. h_other_I:    dc.b    0
  11554. h_other_II:    dc.b    0
  11555. h_with_carry:    dc.b    0
  11556. h_the_flag:    dc.b    0
  11557.  
  11558. mbc1_status:    dc.b    0
  11559. mbc1_ram_protection_status:
  11560.         dc.b    0
  11561. mbc2_ram_protection_status:
  11562.         dc.b    0
  11563. mbc3_ram_protection_status:
  11564.         dc.b    0
  11565.         even
  11566.  
  11567. mbc3_latched_sec:
  11568.         dc.b    0
  11569. mbc3_latched_min:
  11570.         dc.b    0
  11571. mbc3_latched_hrs:
  11572.         dc.b    0
  11573. mbc3_latched_dayl:
  11574.         dc.b    0
  11575. mbc3_latched_dayh:
  11576.         dc.b    0
  11577.  
  11578. mbc3_sec:    dc.b    0
  11579. mbc3_min:    dc.b    0
  11580. mbc3_hrs:    dc.b    0
  11581. mbc3_day:
  11582. mbc3_dayh:    dc.b    0                ;order is important.
  11583. mbc3_dayl:    dc.b    0
  11584.  
  11585. mbc3_latch_a:    dc.b    0
  11586. mbc3_latch_b:    dc.b    0
  11587. mbc3_existence:    dc.b    0
  11588.         even
  11589.  
  11590. mbc5_rom_bank:    dc.w    0
  11591. mbc5_rom_bank1:    dc.b    0
  11592. mbc5_rom_bank0:    dc.b    0
  11593.  
  11594. z80_registers:    ds.l    6+5                ;d0-d5/a0-a4.
  11595.  
  11596. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11597. ;        emulator variables
  11598. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11599.  
  11600. h_values:    dc.b    2,3,3,0,0
  11601.         dc.b    2,3,3,0,0
  11602.         dc.b    2,3,3,0,0
  11603.         dc.b    2,3,3,0,0
  11604.         dc.b    2,3,3,0,0
  11605.         dc.b    2,3,3,0,0
  11606.         dc.b    2,3,3,0,0
  11607.         dc.b    2,3,3,0,0
  11608.         dc.b    2,3,3,0,0
  11609.         dc.b    2,3,3,0,0
  11610.  
  11611.         dc.b    2,3,3,0,0
  11612.         dc.b    2,3,3,0,0
  11613.         dc.b    2,3,3,0,0
  11614.         dc.b    2,3,3,0,0
  11615.         dc.b    2,3,3,0,0
  11616.         dc.b    2,3,3,0,0
  11617.         dc.b    2,3,3,0,0
  11618.         dc.b    2,3,3,0,0
  11619.         dc.b    2,3,3,0,0
  11620.         dc.b    2,3,3,0,0
  11621.  
  11622.         dc.b    2,3,3,0,0
  11623.         dc.b    2,3,3,0,0
  11624.         dc.b    2,3,3,0,0
  11625.         dc.b    2,3,3,0,0
  11626.         dc.b    2,3,3,0,0
  11627.         dc.b    2,3,3,0,0
  11628.         dc.b    2,3,3,0,0
  11629.         dc.b    2,3,3,0,0
  11630.         dc.b    2,3,3,0,0
  11631.         dc.b    2,3,3,0,0
  11632.  
  11633.         dc.b    2,3,3,0,0
  11634.         dc.b    2,3,3,0,0
  11635.         dc.b    2,3,3,0,0
  11636.         dc.b    2,3,3,0,0
  11637.         dc.b    2,3,3,0,0
  11638.         dc.b    2,3,3,0,0
  11639.         dc.b    2,3,3,0,0
  11640.         dc.b    2,3,3,0,0
  11641.         dc.b    2,3,3,0,0
  11642.         dc.b    2,3,3,0,0
  11643.  
  11644.         dc.b    2,3,3,0,0
  11645.         dc.b    2,3,3,0,0
  11646.         dc.b    2,3,3,0,0
  11647.         dc.b    2,3,3,0,0
  11648.         dc.b    2,3,3,0,0
  11649.         dc.b    2,3,3,0,0
  11650.         dc.b    2,3,3,0,0
  11651.         dc.b    2,3,3,0,0
  11652.         dc.b    2,3,3,0,0
  11653.         dc.b    2,3,3,0,0
  11654.  
  11655.         dc.b    2,3,3,0,0
  11656.         dc.b    2,3,3,0,0
  11657.         dc.b    2,3,3,0,0
  11658.         dc.b    2,3,3,0,0
  11659.         dc.b    2,3,3,0,0
  11660.         dc.b    2,3,3,0,0
  11661.         dc.b    2,3,3,0,0
  11662.         dc.b    2,3,3,0,0
  11663.         dc.b    2,3,3,0,0
  11664.         dc.b    2,3,3,0,0
  11665.  
  11666.         dc.b    2,3,3,0,0
  11667.         dc.b    2,3,3,0,0
  11668.         dc.b    2,3,3,0,0
  11669.         dc.b    2,3,3,0,0
  11670.         dc.b    2,3,3,0,0
  11671.         dc.b    2,3,3,0,0
  11672.         dc.b    2,3,3,0,0
  11673.         dc.b    2,3,3,0,0
  11674.         dc.b    2,3,3,0,0
  11675.         dc.b    2,3,3,0,0
  11676.  
  11677.         dc.b    2,3,3,0,0
  11678.         dc.b    2,3,3,0,0
  11679.         dc.b    2,3,3,0,0
  11680.         dc.b    2,3,3,0,0
  11681.         dc.b    2,3,3,0,0
  11682.         dc.b    2,3,3,0,0
  11683.         dc.b    2,3,3,0,0
  11684.         dc.b    2,3,3,0,0
  11685.         dc.b    2,3,3,0,0
  11686.         dc.b    2,3,3,0,0
  11687.  
  11688.         dc.b    2,3,3,0,0
  11689.         dc.b    2,3,3,0,0
  11690.         dc.b    2,3,3,0,0
  11691.         dc.b    2,3,3,0,0
  11692.         dc.b    2,3,3,0,0
  11693.         dc.b    2,3,3,0,0
  11694.         dc.b    2,3,3,0,0
  11695.         dc.b    2,3,3,0,0
  11696.         dc.b    2,3,3,0,0
  11697.         dc.b    2,3,3,0,0
  11698.  
  11699.         dc.b    2,3,3,0,0
  11700.         dc.b    2,3,3,0,0
  11701.         dc.b    2,3,3,0,0
  11702.         dc.b    2,3,3,0,0
  11703.         dc.b    2,3,3,0,0
  11704.         dc.b    2,3,3,0,0
  11705.         dc.b    2,3,3,0,0
  11706.         dc.b    2,3,3,0,0
  11707.         dc.b    2,3,3,0,0
  11708.         dc.b    2,3,3,0,0
  11709.  
  11710.         dc.b    2,3,3,0,0
  11711.         dc.b    2,3,3,0,0
  11712.         dc.b    2,3,3,0,0
  11713.         dc.b    2,3,3,0,0
  11714.         dc.b    2,3,3,0,0
  11715.         dc.b    2,3,3,0,0
  11716.         dc.b    2,3,3,0,0
  11717.         dc.b    2,3,3,0,0
  11718.         dc.b    2,3,3,0,0
  11719.         dc.b    2,3,3,0,0
  11720.  
  11721.         dc.b    2,3,3,0,0
  11722.         dc.b    2,3,3,0,0
  11723.         dc.b    2,3,3,0,0
  11724.         dc.b    2,3,3,0,0
  11725.         dc.b    2,3,3,0,0
  11726.         dc.b    2,3,3,0,0
  11727.         dc.b    2,3,3,0,0
  11728.         dc.b    2,3,3,0,0
  11729.         dc.b    2,3,3,0,0
  11730.         dc.b    2,3,3,0,0
  11731.  
  11732.         dc.b    2,3,3,0,0
  11733.         dc.b    2,3,3,0,0
  11734.         dc.b    2,3,3,0,0
  11735.         dc.b    2,3,3,0,0
  11736.         dc.b    2,3,3,0,0
  11737.         dc.b    2,3,3,0,0
  11738.         dc.b    2,3,3,0,0
  11739.         dc.b    2,3,3,0,0
  11740.         dc.b    2,3,3,0,0
  11741.         dc.b    2,3,3,0,0
  11742.  
  11743.         dc.b    2,3,3,0,0
  11744.         dc.b    2,3,3,0,0
  11745.         dc.b    2,3,3,0,0
  11746.         dc.b    2,3,3,0,0
  11747.         dc.b    2,3,3,0,0
  11748.         dc.b    2,3,3,0,0
  11749.         dc.b    2,3,3,0,0
  11750.         dc.b    2,3,3,0,0
  11751.         dc.b    2,3,3,0,0
  11752.         dc.b    2,3,3,0,0
  11753.  
  11754.         dc.b    2,3,3,0,0
  11755.         dc.b    2,3,3,0,0
  11756.         dc.b    2,3,3,0,0
  11757.         dc.b    2,3,3,0,0
  11758.         dc.b    1,1,1,1,1
  11759.         dc.b    1,1,1,1,1
  11760.         dc.b    1,1,1,1,1
  11761.         dc.b    1,1,1,1,1
  11762.         dc.b    1,1,1,1,1
  11763.         dc.b    1,1,1,1,1
  11764.  
  11765.         dc.b    1,1,1,1,1
  11766.         dc.b    1,1,1,1,1
  11767.         dc.b    1,1,1,1,1
  11768.         dc.b    1,1,0,0,0
  11769.         even
  11770.  
  11771. h_values_indexed:
  11772.         dc.l    0
  11773.  
  11774. visual_frame:    dc.b    0                ;used buffer number.
  11775.         even
  11776.  
  11777. bitmap_bg:    dc.l    0                ;planes 0 and 1 (c).
  11778. bitmap_spc:    dc.l    0                ;planes 2 and 3 (c).
  11779.  
  11780. gb_scanlines:    dc.l    0
  11781. cartridge:    dc.l    0                ;pointer to a cartridge.
  11782. cartridge_data:    dc.l    0
  11783.  
  11784. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11785. ;        variables for x flipper and rom input supervisor
  11786. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11787.  
  11788. x_flip_table:    dc.l    0
  11789. rom_32k:    dc.l    0
  11790.  
  11791. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11792. ;        aga h/w mode variables
  11793. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11794.  
  11795. copper_I:    dc.l    0
  11796. copper_II:    dc.l    0
  11797. copper_inactive:dc.l    0
  11798.  
  11799. aga_scr_0_cI:    dc.l    0
  11800. aga_scr_cI:    dc.l    0
  11801. aga_spr_cI:    dc.l    0
  11802. aga_pln_cI:    dc.l    0
  11803. aga_col_cI:    dc.l    0
  11804. aga_hw_spr_cI:    dc.l    0
  11805.  
  11806. aga_map_I:    dc.l    0
  11807. aga_map_II:    dc.l    0
  11808. aga_map_inactive:
  11809.         dc.l    0
  11810.  
  11811. aga_col_bg:    dc.l    0
  11812. aga_col_sprs:    dc.l    0
  11813. gb_x:        dc.l    0                ;scroll x for the screen.
  11814. aga_spr_amount:    dc.l    0                ;max 10.
  11815.  
  11816. aga_ro_list_I:    dc.l    0
  11817. aga_ro_list_II:    dc.l    0
  11818. aga_ro_inactive:dc.l    0
  11819.  
  11820. aga_sprs_cI:    dc.l    0
  11821. aga_sprs_cII:    dc.l    0
  11822. aga_sprs_cxI:    dc.l    0
  11823. aga_sprs_cxII:    dc.l    0
  11824. aga_sprs_inactive:
  11825.         dc.l    0
  11826. aga_sprs_inactive_x:
  11827.         dc.l    0
  11828.  
  11829. aga_spr_Ia:    dc.l    0                ;sprite I.
  11830. aga_spr_IIa:    dc.l    0                ;       II.
  11831. aga_spr_IIIa:    dc.l    0                ;       III.
  11832. aga_spr_Ib:    dc.l    0                ;sprite I.
  11833. aga_spr_IIb:    dc.l    0                ;       II.
  11834. aga_spr_IIIb:    dc.l    0                ;       III.
  11835. aga_spr_Ix:    dc.l    0                ;mask sprite I.
  11836. aga_spr_IIx:    dc.l    0                ;            II.
  11837. aga_spr_IIIx:    dc.l    0                ;            III.
  11838. aga_spr_empty:    dc.l    0                ;empty sprite data.
  11839.  
  11840. aga_spr_inactive_pointer:
  11841.         dc.l    0
  11842.  
  11843. aga_palette_byte:
  11844.         dc.b    0
  11845.         even
  11846.  
  11847. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11848. ;        variables for screen_draw.s
  11849. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11850.  
  11851. bg_scroll_y:    dc.l    0
  11852. bg_scroll_y_I:    dc.l    0                ;screen scroll y.
  11853. bg_scroll_y_II:    dc.l    0
  11854. bg_scroll_inactive:
  11855.         dc.l    0
  11856.  
  11857. bg_scroll_x:    dc.l    0                ;screen scroll x.
  11858. lcd_control:    dc.l    0                ;lcd control byte.
  11859.  
  11860. sprite_y:    dc.l    0                ;sprite y storage (7/15).
  11861. sprite_sign:    dc.l    0                ;(sprite_y/4)-1.
  11862. win_x:        dc.l    0                ;window x start position.
  11863. tile_adder:    dc.l    0                ;room for signed/unsigned adder.
  11864. tile_adder_x:    dc.l    0
  11865. x_counter:    dc.l    0                ;room for a counter.
  11866. gb_tiles:    dc.l    0
  11867.  
  11868. spr_win_flag:    dc.b    0                ;0 = beyond / 1 = before.
  11869. output_bit:    dc.b    0                ;for frame skipping.
  11870. frame_update:    dc.b    1                ;skip this many - 1 frames.
  11871. frame_update_number:
  11872.         dc.b    0                ;frame_update - 1.
  11873. sprite_mask:    dc.b    0
  11874.         even
  11875.  
  11876. gb_pal:        dc.w    16                ;16 colours.
  11877.         dc.w    0                ;the first colour.
  11878. gb_pale:    ds.l    3*16                ;the colours.
  11879.         dc.l    0                ;the end of the list.
  11880.  
  11881. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11882. ;        universal window tags
  11883. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11884.  
  11885. win_tags_u:    dc.l    WA_NewLookMenus,TRUE
  11886.         dc.l    WA_AutoAdjust,TRUE
  11887.         dc.l    TAG_END,0            ;3d look, here too.
  11888.  
  11889. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11890. ;        menu window
  11891. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11892.  
  11893. menu_ptr:    dc.l    0
  11894.  
  11895. menu_window:    dc.w    0
  11896.         dc.w    11
  11897.         dc.w    menu_x
  11898.         dc.w    menu_y
  11899.         dc.b    0
  11900.         dc.b    1
  11901.         dc.l    menu_idcmp
  11902.         dc.l    menu_flags
  11903.         dc.l    0
  11904.         dc.l    0
  11905.         dc.l    menu_title
  11906.         dc.l    0
  11907.         dc.l    0
  11908.         dc.w    0
  11909.         dc.w    0
  11910.         dc.w    menu_x
  11911.         dc.w    menu_y
  11912.         dc.w    WBENCHSCREEN
  11913.  
  11914. menu_title:    dc.b    "Wzonka-Lad 1.03.00"
  11915.         dc.b    " (680x0)",0
  11916.         even
  11917.  
  11918. menu_b_1:    dc.l    0
  11919. menu_b_2:    dc.l    0
  11920. menu_b_3:    dc.l    0
  11921. menu_b_4:    dc.l    0
  11922. menu_b_5:    dc.l    0
  11923. menu_b_6:    dc.l    0
  11924. menu_b_7:    dc.l    0
  11925. menu_b_8:    dc.l    0
  11926. menu_b_9:    dc.l    0
  11927. menu_b_10:    dc.l    0
  11928. menu_b_11:    dc.l    0
  11929.  
  11930. menu_b_1_txt:    dc.b    "_Load",0
  11931.         even
  11932. menu_b_2_txt:    dc.b    "_Run",0
  11933.         even
  11934. menu_b_3_txt:    dc.b    "_Info",0
  11935.         even
  11936. menu_b_4_txt:    dc.b    "L_oad",0
  11937.         even
  11938. menu_b_5_txt:    dc.b    "S_ave",0
  11939.         even
  11940. menu_b_6_txt:    dc.b    "A_bout",0
  11941.         even
  11942. menu_b_7_txt:    dc.b    "_Gfx",0
  11943.         even
  11944. menu_b_8_txt:    dc.b    "_Sfx",0
  11945.         even
  11946. menu_b_9_txt:    dc.b    "_Prefs",0
  11947.         even
  11948. menu_b_10_txt:    dc.b    "_Misc",0
  11949.         even
  11950. menu_b_11_txt:    dc.b    "R_eset",0
  11951.         even
  11952.  
  11953. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11954. ;        function window
  11955. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11956.  
  11957. function_ptr:    dc.l    0
  11958.  
  11959. function_window:dc.w    240-16
  11960.         dc.w    11+11
  11961.         dc.w    function_x
  11962.         dc.w    function_y
  11963.         dc.b    0
  11964.         dc.b    1
  11965.         dc.l    function_idcmp
  11966.         dc.l    function_flags
  11967.         dc.l    0
  11968.         dc.l    0
  11969.         dc.l    function_title
  11970.         dc.l    0
  11971.         dc.l    0
  11972.         dc.w    0
  11973.         dc.w    0
  11974.         dc.w    function_x
  11975.         dc.w    function_y
  11976.         dc.w    WBENCHSCREEN
  11977.  
  11978. function_title:    dc.b    "Functions",0
  11979.         even
  11980.  
  11981. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11982. ;        context gadgets
  11983. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11984.  
  11985. context_g_gfx:    dc.l    0
  11986. context_g_menu:    dc.l    0
  11987. context_g_prefs:dc.l    0
  11988. context_g_sfx:    dc.l    0
  11989. context_g_misc:    dc.l    0
  11990.  
  11991. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11992. ;        misc gadgets
  11993. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  11994.  
  11995. misc_strings_x    =70
  11996. misc_strings_dx    =44
  11997.  
  11998. misc_b_1:    dc.l    0
  11999. misc_b_2:    dc.l    0
  12000. misc_b_3:    dc.l    0
  12001. misc_b_6:    dc.l    0
  12002. misc_b_str_1:    dc.l    0
  12003. misc_b_str_2:    dc.l    0
  12004. misc_b_str_3:    dc.l    0
  12005. misc_b_code_list:
  12006.         dc.l    0
  12007.  
  12008. misc_str_1:    dc.l    0
  12009. misc_str_2:    dc.l    0
  12010. misc_str_3:    dc.l    0
  12011.  
  12012. misc_g_y    =36
  12013.  
  12014. misc_gadgets:    dc.w    100,misc_g_y
  12015.         dc.l    PLACETEXT_RIGHT
  12016.         dc.l    misc_b_1_txt
  12017.         dc.w    0
  12018.         dc.w    5                ;checkbox_kind!
  12019.         dc.l    alter_tags_checkbox
  12020.         dc.l    forbid_permit_status
  12021.         dc.l    misc_b_1
  12022.  
  12023.         dc.w    100,misc_g_y+13
  12024.         dc.l    PLACETEXT_RIGHT
  12025.         dc.l    misc_b_2_txt
  12026.         dc.w    1
  12027.         dc.w    5                ;checkbox_kind!
  12028.         dc.l    alter_tags_checkbox
  12029.         dc.l    os_screen_speed_limit
  12030.         dc.l    misc_b_2
  12031.  
  12032.         dc.w    100,misc_g_y+13*2
  12033.         dc.l    PLACETEXT_RIGHT
  12034.         dc.l    misc_b_6_txt
  12035.         dc.w    6
  12036.         dc.w    5                ;checkbox_kind!
  12037.         dc.l    alter_tags_checkbox
  12038.         dc.l    fast_ram_bitmaps
  12039.         dc.l    misc_b_6
  12040.  
  12041.         dc.w    260,58+misc_g_y
  12042.         dc.l    PLACETEXT_IN
  12043.         dc.l    misc_b_3_txt
  12044.         dc.w    2
  12045.         dc.w    0                ;button_kind!
  12046.         dc.w    50,14
  12047.         dc.l    misc_b_3
  12048.  
  12049.         dc.w    misc_strings_x,59+misc_g_y
  12050.         dc.l    PLACETEXT_LEFT
  12051.         dc.l    misc_b_str_1_txt
  12052.         dc.w    3
  12053.         dc.w    2                ;string_kind!
  12054.         dc.w    misc_strings_dx,13
  12055.         dc.l    misc_b_str_tgs
  12056.         dc.l    misc_str_1
  12057.         dc.l    misc_b_str_1
  12058.  
  12059.         dc.w    misc_strings_x+misc_strings_dx+24,59+misc_g_y
  12060.         dc.l    PLACETEXT_LEFT
  12061.         dc.l    misc_b_str_2_txt
  12062.         dc.w    4
  12063.         dc.w    2                ;string_kind!
  12064.         dc.w    misc_strings_dx,13
  12065.         dc.l    misc_b_str_tgs
  12066.         dc.l    misc_str_2
  12067.         dc.l    misc_b_str_2
  12068.  
  12069.         dc.w    misc_strings_x+misc_strings_dx*2+24*2,59+misc_g_y
  12070.         dc.l    PLACETEXT_LEFT
  12071.         dc.l    misc_b_str_3_txt
  12072.         dc.w    5
  12073.         dc.w    2                ;string_kind!
  12074.         dc.w    misc_strings_dx,13
  12075.         dc.l    misc_b_str_tgs
  12076.         dc.l    misc_str_3
  12077.         dc.l    misc_b_str_3
  12078.  
  12079.         dc.w    55,78+misc_g_y
  12080.         dc.l    PLACETEXT_LEFT
  12081.         dc.l    sfx_empty
  12082.         dc.w    7
  12083.         dc.w    3                ;listview_kind!
  12084.         dc.w    270,50
  12085.         dc.l    misc_b_code_list_tags
  12086.         dc.l    misc_b_code_list_selected
  12087.         dc.l    misc_b_code_list
  12088.  
  12089.         dc.l    0                ;end of list.
  12090.  
  12091. misc_b_code_list_tags:
  12092.         dc.l    GTLV_Labels,0
  12093.         dc.l    GTLV_Selected,0
  12094.         dc.l    GTLV_MakeVisible,0
  12095.         dc.l    GTLV_ShowSelected,0
  12096.         dc.l    TAG_END,0
  12097.  
  12098. misc_b_code_list_change_tags:
  12099.         dc.l    GTLV_Labels,0
  12100.         dc.l    TAG_END,0
  12101.  
  12102. misc_b_str_tgs:    dc.l    GTST_String,0
  12103.         dc.l    GTST_MaxChars,3
  12104.         dc.l    GA_TabCycle,TRUE
  12105.         dc.l    STRINGA_Justification,GACT_STRINGLEFT
  12106.         dc.l    STRINGA_ReplaceMode,FALSE
  12107.         dc.l    TAG_END,0
  12108.  
  12109. misc_b_1_txt:    dc.b    "Multitasking",0
  12110.         even
  12111. misc_b_2_txt:    dc.b    "OS screen speed limit",0
  12112.         even
  12113. misc_b_3_txt:    dc.b    "Patch",0
  12114.         even
  12115. misc_b_6_txt:    dc.b    "Bitmaps in FAST RAM",0
  12116.         even
  12117.  
  12118. misc_b_str_1_txt:
  12119.         dc.b    " ",0
  12120.         even
  12121. misc_b_str_2_txt:
  12122.         dc.b    "-",0
  12123.         even
  12124. misc_b_str_3_txt:
  12125.         dc.b    "-",0
  12126.         even
  12127.  
  12128. misc_text_1:    dc.b    2
  12129.         dc.b    0
  12130.         dc.b    0
  12131.         dc.b    0
  12132.         dc.w    170
  12133.         dc.w    misc_g_y-14
  12134.         dc.l    font_attr
  12135.         dc.l    misc_txt_1
  12136.         dc.l    misc_text_2
  12137.  
  12138. misc_text_2:    dc.b    2
  12139.         dc.b    0
  12140.         dc.b    0
  12141.         dc.b    0
  12142.         dc.w    122
  12143.         dc.w    misc_g_y+45
  12144.         dc.l    font_attr
  12145.         dc.l    misc_txt_2
  12146.         dc.l    0
  12147.  
  12148. misc_txt_1:    dc.b    "Misc",0
  12149.         even
  12150. misc_txt_2:    dc.b    "GameGenie patch code",0
  12151.         even
  12152.  
  12153. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  12154. ;        menu gadgets
  12155. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  12156.  
  12157. menu_scr_txt:    dc.b    "Wzonka-Lad 1.03.00"
  12158.         dc.b    " GPL release",0
  12159.         even
  12160.  
  12161. menu_b_x    =56-16-8
  12162. menu_b_y    =34-14
  12163. menu_b_width    =60
  12164. menu_b_height    =14
  12165. menu_b_distance    =88
  12166.  
  12167. menu_gadgets:    dc.w    menu_b_x,menu_b_y
  12168.         dc.l    PLACETEXT_IN
  12169.         dc.l    menu_b_1_txt
  12170.         dc.w    0
  12171.         dc.w    0                ;button_kind!
  12172.         dc.w    menu_b_width,menu_b_height
  12173.         dc.l    menu_b_1
  12174.  
  12175.         dc.w    menu_b_x,menu_b_y+15
  12176.         dc.l    PLACETEXT_IN
  12177.         dc.l    menu_b_2_txt
  12178.         dc.w    1
  12179.         dc.w    0                ;button_kind!
  12180.         dc.w    menu_b_width,menu_b_height
  12181.         dc.l    menu_b_2
  12182.  
  12183.         dc.w    menu_b_x,menu_b_y+15*3
  12184.         dc.l    PLACETEXT_IN
  12185.         dc.l    menu_b_3_txt
  12186.         dc.w    2
  12187.         dc.w    0                ;button_kind!
  12188.         dc.w    menu_b_width,menu_b_height
  12189.         dc.l    menu_b_3
  12190.  
  12191.         dc.w    menu_b_x+menu_b_distance,menu_b_y
  12192.         dc.l    PLACETEXT_IN
  12193.         dc.l    menu_b_4_txt
  12194.         dc.w    3
  12195.         dc.w    0                ;button_kind!
  12196.         dc.w    menu_b_width,menu_b_height
  12197.         dc.l    menu_b_4
  12198.  
  12199.         dc.w    menu_b_x+menu_b_distance,menu_b_y+15
  12200.         dc.l    PLACETEXT_IN
  12201.         dc.l    menu_b_5_txt
  12202.         dc.w    4
  12203.         dc.w    0                ;button_kind!
  12204.         dc.w    menu_b_width,menu_b_height
  12205.         dc.l    menu_b_5
  12206.  
  12207.         dc.w    menu_b_x+menu_b_distance,menu_b_y+15*2+12
  12208.         dc.l    PLACETEXT_IN
  12209.         dc.l    menu_b_6_txt
  12210.         dc.w    5
  12211.         dc.w    0                ;button_kind!
  12212.         dc.w    menu_b_width,menu_b_height
  12213.         dc.l    menu_b_6
  12214.  
  12215.         dc.w    menu_b_x+menu_b_distance*2,menu_b_y
  12216.         dc.l    PLACETEXT_IN
  12217.         dc.l    menu_b_7_txt
  12218.         dc.w    6
  12219.         dc.w    0                ;button_kind!
  12220.         dc.w    menu_b_width,menu_b_height
  12221.         dc.l    menu_b_7
  12222.  
  12223.         dc.w    menu_b_x+menu_b_distance*2,menu_b_y+15
  12224.         dc.l    PLACETEXT_IN
  12225.         dc.l    menu_b_8_txt
  12226.         dc.w    7
  12227.         dc.w    0                ;button_kind!
  12228.         dc.w    menu_b_width,menu_b_height
  12229.         dc.l    menu_b_8
  12230.  
  12231.         dc.w    menu_b_x+menu_b_distance*2,menu_b_y+15*2
  12232.         dc.l    PLACETEXT_IN
  12233.         dc.l    menu_b_9_txt
  12234.         dc.w    8
  12235.         dc.w    0                ;button_kind!
  12236.         dc.w    menu_b_width,menu_b_height
  12237.         dc.l    menu_b_9
  12238.  
  12239.         dc.w    menu_b_x+menu_b_distance*2,menu_b_y+15*3
  12240.         dc.l    PLACETEXT_IN
  12241.         dc.l    menu_b_10_txt
  12242.         dc.w    9
  12243.         dc.w    0                ;button_kind!
  12244.         dc.w    menu_b_width,menu_b_height
  12245.         dc.l    menu_b_10
  12246.  
  12247.         dc.w    menu_b_x,menu_b_y+15*2
  12248.         dc.l    PLACETEXT_IN
  12249.         dc.l    menu_b_11_txt
  12250.         dc.w    10
  12251.         dc.w    0                ;button_kind!
  12252.         dc.w    menu_b_width,menu_b_height
  12253.         dc.l    menu_b_11
  12254.  
  12255.         dc.l    0                ;end of the list.
  12256.  
  12257. menu_text_1:    dc.b    2
  12258.         dc.b    0
  12259.         dc.b    0
  12260.         dc.b    0
  12261.         dc.w    76-16-8
  12262.         dc.w    21-14
  12263.         dc.l    font_attr
  12264.         dc.l    menu_txt_1
  12265.         dc.l    menu_text_2
  12266.  
  12267. menu_text_2:    dc.b    2
  12268.         dc.b    0
  12269.         dc.b    0
  12270.         dc.b    0
  12271.         dc.w    164-16-8
  12272.         dc.w    21-14
  12273.         dc.l    font_attr
  12274.         dc.l    menu_txt_2
  12275.         dc.l    menu_text_3
  12276.  
  12277. menu_text_3:    dc.b    2
  12278.         dc.b    0
  12279.         dc.b    0
  12280.         dc.b    0
  12281.         dc.w    252-16-8
  12282.         dc.w    21-14
  12283.         dc.l    font_attr
  12284.         dc.l    menu_txt_3
  12285.         dc.l    0
  12286.  
  12287. menu_txt_1:    dc.b    "ROM",0
  12288.         even
  12289. menu_txt_2:    dc.b    "GBS",0
  12290.         even
  12291. menu_txt_3:    dc.b    "Edit",0
  12292.         even
  12293.  
  12294. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  12295. ;        prefs gadgets
  12296. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  12297.  
  12298. prefs_g_battery:dc.l    0
  12299. prefs_g_battery_status:
  12300.         dc.l    0
  12301. prefs_g_gbs:    dc.l    0
  12302. prefs_g_joy:    dc.l    0
  12303. prefs_g_str_1:    dc.l    0
  12304. prefs_g_str_2:    dc.l    0
  12305. prefs_g_str_3:    dc.l    0
  12306. prefs_g_str_4:    dc.l    0
  12307. prefs_g_get_1:    dc.l    0
  12308. prefs_g_get_2:    dc.l    0
  12309. prefs_g_get_3:    dc.l    0
  12310. prefs_g_get_4:    dc.l    0
  12311. prefs_g_rom:    dc.l    0
  12312. prefs_g_default:dc.l    0
  12313. prefs_g_xpk:    dc.l    0
  12314.  
  12315. joy_names_list:    dc.l    0
  12316.  
  12317. prefs_g_xpk_l:    dc.l    GTLV_Labels,0
  12318.         dc.l    GTLV_Selected,0
  12319.         dc.l    GTLV_MakeVisible,0
  12320.         dc.l    GTLV_ShowSelected,0
  12321.         dc.l    TAG_END,0
  12322.  
  12323. prefs_g_joy_l:    dc.l    GTLV_Labels,0
  12324.         dc.l    GTLV_Selected,0
  12325.         dc.l    GTLV_MakeVisible,0
  12326.         dc.l    GTLV_ShowSelected,0
  12327.         dc.l    TAG_END,0
  12328.  
  12329. prefs_g_str_tgs:dc.l    GTST_String,0
  12330.         dc.l    GTST_MaxChars,128
  12331.         dc.l    GA_TabCycle,TRUE
  12332.         dc.l    STRINGA_Justification,GACT_STRINGLEFT
  12333.         dc.l    STRINGA_ReplaceMode,FALSE
  12334.         dc.l    TAG_END,0
  12335.  
  12336. prefs_g_str_chg:dc.l    GTST_String,0
  12337.         dc.l    TAG_END,0
  12338.  
  12339. prefs_str_ptr:    dc.l    0
  12340.  
  12341. prefs_rom:    dc.b    "ROM",0
  12342.         even
  12343. prefs_gbs:    dc.b    "GBS",0
  12344.         even
  12345. prefs_prefs:    dc.b    "Prefs",0
  12346.         even
  12347. prefs_battery:    dc.b    "Battery",0
  12348.         even
  12349. prefs_get:    dc.b    "Get",0
  12350.         even
  12351. prefs_battery_ram:
  12352.         dc.b    "Battery RAM",0
  12353.         even
  12354. prefs_default:    dc.b    "Default",0
  12355.         even
  12356.  
  12357. string_x    =90
  12358. string_y    =15
  12359. string_dx    =200
  12360. string_dy    =13
  12361. string_b_dx    =40
  12362. string_b_dy    =13
  12363.  
  12364. prefs_gadgets:    dc.w    string_x,string_y
  12365.         dc.l    PLACETEXT_LEFT
  12366.         dc.l    prefs_rom
  12367.         dc.w    0
  12368.         dc.w    2                ;string_kind!
  12369.         dc.w    string_dx,string_dy
  12370.         dc.l    prefs_g_str_tgs
  12371.         dc.l    prefs_str_1
  12372.         dc.l    prefs_g_str_1
  12373.  
  12374.         dc.w    string_x,string_y+string_dy+1
  12375.         dc.l    PLACETEXT_LEFT
  12376.         dc.l    prefs_gbs
  12377.         dc.w    1
  12378.         dc.w    2                ;string_kind!
  12379.         dc.w    string_dx,string_dy
  12380.         dc.l    prefs_g_str_tgs
  12381.         dc.l    prefs_str_2
  12382.         dc.l    prefs_g_str_2
  12383.  
  12384.         dc.w    string_x,string_y+string_dy*2+1*2
  12385.         dc.l    PLACETEXT_LEFT
  12386.         dc.l    prefs_prefs
  12387.         dc.w    2
  12388.         dc.w    2                ;string_kind!
  12389.         dc.w    string_dx,string_dy
  12390.         dc.l    prefs_g_str_tgs
  12391.         dc.l    prefs_str_3
  12392.         dc.l    prefs_g_str_3
  12393.  
  12394.         dc.w    string_x,string_y+string_dy*3+1*3
  12395.         dc.l    PLACETEXT_LEFT
  12396.         dc.l    prefs_battery
  12397.         dc.w    3
  12398.         dc.w    2                ;string_kind!
  12399.         dc.w    string_dx,string_dy
  12400.         dc.l    prefs_g_str_tgs
  12401.         dc.l    prefs_str_4
  12402.         dc.l    prefs_g_str_4
  12403.  
  12404.         dc.w    string_x+string_dx+10,string_y
  12405.         dc.l    PLACETEXT_IN
  12406.         dc.l    prefs_get
  12407.         dc.w    4
  12408.         dc.w    0                ;button_kind!
  12409.         dc.w    string_b_dx,string_b_dy
  12410.         dc.l    prefs_g_get_1
  12411.  
  12412.         dc.w    string_x+string_dx+10,string_y+string_dy+1
  12413.         dc.l    PLACETEXT_IN
  12414.         dc.l    prefs_get
  12415.         dc.w    5
  12416.         dc.w    0                ;button_kind!
  12417.         dc.w    string_b_dx,string_b_dy
  12418.         dc.l    prefs_g_get_2
  12419.  
  12420.         dc.w    string_x+string_dx+10,string_y+string_dy*2+1*2
  12421.         dc.l    PLACETEXT_IN
  12422.         dc.l    prefs_get
  12423.         dc.w    6
  12424.         dc.w    0                ;button_kind!
  12425.         dc.w    string_b_dx,string_b_dy
  12426.         dc.l    prefs_g_get_3
  12427.  
  12428.         dc.w    string_x+string_dx+10,string_y+string_dy*3+1*3
  12429.         dc.l    PLACETEXT_IN
  12430.         dc.l    prefs_get
  12431.         dc.w    7
  12432.         dc.w    0                ;button_kind!
  12433.         dc.w    string_b_dx,string_b_dy
  12434.         dc.l    prefs_g_get_4
  12435.  
  12436.         dc.w    40,107
  12437.         dc.l    PLACETEXT_LEFT
  12438.         dc.l    sfx_empty
  12439.         dc.w    8
  12440.         dc.w    3                ;listview_kind!
  12441.         dc.w    64,40
  12442.         dc.l    prefs_g_xpk_l
  12443.         dc.l    pck_method_number
  12444.         dc.l    prefs_g_xpk
  12445.  
  12446.         dc.w    144,90
  12447.         dc.l    PLACETEXT_RIGHT
  12448.         dc.l    prefs_battery_ram
  12449.         dc.w    9
  12450.         dc.w    1                ;mx_kind!
  12451.         dc.l    mx_tags
  12452.         dc.l    on_off_txt_list
  12453.         dc.l    battery_xpk_status
  12454.         dc.l    prefs_g_battery
  12455.  
  12456.         dc.w    144,112
  12457.         dc.l    PLACETEXT_RIGHT
  12458.         dc.l    prefs_gbs
  12459.         dc.w    10
  12460.         dc.w    1                ;mx_kind!
  12461.         dc.l    mx_tags
  12462.         dc.l    on_off_txt_list
  12463.         dc.l    pck_xpk_status
  12464.         dc.l    prefs_g_gbs
  12465.  
  12466.         dc.w    244,93
  12467.         dc.l    PLACETEXT_LEFT
  12468.         dc.l    sfx_empty
  12469.         dc.w    11
  12470.         dc.w    3                ;listview_kind!
  12471.         dc.w    90,48
  12472.         dc.l    prefs_g_joy_l
  12473.         dc.l    keystick
  12474.         dc.l    prefs_g_joy
  12475.  
  12476.         dc.w    40,165
  12477.         dc.l    PLACETEXT_IN
  12478.         dc.l    prefs_default
  12479.         dc.w    12
  12480.         dc.w    0                ;button_kind!
  12481.         dc.w    80,string_b_dy
  12482.         dc.l    prefs_g_default
  12483.  
  12484.         dc.w    40+80+8,165
  12485.         dc.l    PLACETEXT_IN
  12486.         dc.l    prefs_rom
  12487.         dc.w    14
  12488.         dc.w    0                ;button_kind!
  12489.         dc.w    58,string_b_dy
  12490.         dc.l    prefs_g_rom
  12491.  
  12492.         dc.w    294,159
  12493.         dc.l    PLACETEXT_RIGHT
  12494.         dc.l    prefs_battery
  12495.         dc.w    13
  12496.         dc.w    1                ;mx_kind!
  12497.         dc.l    mx_tags
  12498.         dc.l    on_off_txt_list
  12499.         dc.l    battery_status
  12500.         dc.l    prefs_g_battery_status
  12501.  
  12502.         dc.l    0
  12503.  
  12504. prefs_str_1:    dc.l    0
  12505. prefs_str_2:    dc.l    0
  12506. prefs_str_3:    dc.l    0
  12507. prefs_str_4:    dc.l    0
  12508.  
  12509. prefs_text_1:    dc.b    2
  12510.         dc.b    0
  12511.         dc.b    0
  12512.         dc.b    0
  12513.         dc.w    170
  12514.         dc.w    2
  12515.         dc.l    font_attr
  12516.         dc.l    prefs_txt_1
  12517.         dc.l    prefs_text_2
  12518.  
  12519. prefs_text_2:    dc.b    2
  12520.         dc.b    0
  12521.         dc.b    0
  12522.         dc.b    0
  12523.         dc.w    35
  12524.         dc.w    78
  12525.         dc.l    font_attr
  12526.         dc.l    prefs_txt_2
  12527.         dc.l    prefs_text_3
  12528.  
  12529. prefs_text_3:    dc.b    2
  12530.         dc.b    0
  12531.         dc.b    0
  12532.         dc.b    0
  12533.         dc.w    258
  12534.         dc.w    78
  12535.         dc.l    font_attr
  12536.         dc.l    prefs_txt_3
  12537.         dc.l    prefs_text_4
  12538.  
  12539. prefs_text_4:    dc.b    2
  12540.         dc.b    0
  12541.         dc.b    0
  12542.         dc.b    0
  12543.         dc.w    56
  12544.         dc.w    152
  12545.         dc.l    font_attr
  12546.         dc.l    prefs_txt_4
  12547.         dc.l    prefs_text_5
  12548.  
  12549. prefs_text_5:    dc.b    2
  12550.         dc.b    0
  12551.         dc.b    0
  12552.         dc.b    0
  12553.         dc.w    278
  12554.         dc.w    146
  12555.         dc.l    font_attr
  12556.         dc.l    prefs_txt_5
  12557.         dc.l    0
  12558.  
  12559. prefs_txt_1:    dc.b    "Paths",0
  12560.         even
  12561. prefs_txt_2:    dc.b    "XPK packing when saving",0
  12562.         even
  12563. prefs_txt_3:    dc.b    "Controller",0
  12564.         even
  12565. prefs_txt_4:    dc.b    "Save preferences",0
  12566.         even
  12567. prefs_txt_5:    dc.b    "RAM",0
  12568.         even
  12569.  
  12570. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  12571. ;        sfx gadgets
  12572. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  12573.  
  12574. sfx_g_audio:    dc.l    0
  12575. sfx_g_quality:    dc.l    0
  12576. sfx_g_c_1:    dc.l    0
  12577. sfx_g_c_2:    dc.l    0
  12578. sfx_g_c_3:    dc.l    0
  12579. sfx_g_c_4:    dc.l    0
  12580. sfx_g_ahi_mode:    dc.l    0
  12581. sfx_g_y_hz:    dc.l    0
  12582. sfx_g_volume:    dc.l    0
  12583.  
  12584. mx_tags:    dc.l    GTMX_Labels,0
  12585.         dc.l    GTMX_Active,0
  12586.         dc.l    GTMX_Spacing,2
  12587.         dc.l    GTMX_TitlePlace,PLACETEXT_LEFT
  12588.         dc.l    TAG_END,0
  12589.  
  12590. mx_special_tags:dc.l    GTMX_Labels,0
  12591.         dc.l    GTMX_Active,0
  12592.         dc.l    GTMX_Spacing,10
  12593.         dc.l    GTMX_TitlePlace,PLACETEXT_LEFT
  12594.         dc.l    TAG_END,0
  12595.  
  12596. alter_tags_slider:
  12597.         dc.l    GTSL_Level,0
  12598.         dc.l    TAG_END,0
  12599.  
  12600. alter_tags_mx:    dc.l    GTMX_Active,0
  12601.         dc.l    TAG_END,0
  12602.  
  12603. alter_tags_checkbox:
  12604.         dc.l    GTCB_Checked,0
  12605.         dc.l    TAG_END,0
  12606.  
  12607. on_off_txt_list:dc.l    sfx_on
  12608.         dc.l    sfx_off
  12609.         dc.l    0
  12610.  
  12611. sfx_quality_txt:dc.l    sfx_high
  12612.         dc.l    sfx_low
  12613.         dc.l    sfx_y_hz
  12614.         dc.l    0
  12615.  
  12616. sfx_audio:    dc.b    "Audio",0
  12617.         even
  12618. sfx_on:        dc.b    "On",0
  12619.         even
  12620. sfx_off:    dc.b    "Off",0
  12621.         even
  12622. sfx_quality:    dc.b    "Quality",0
  12623.         even
  12624. sfx_high:    dc.b    "High",0
  12625.         even
  12626. sfx_low:    dc.b    "Low",0
  12627.         even
  12628. sfx_y_hz:    dc.b    "y Hz",0
  12629.         even
  12630. sfx_y:        dc.b    "y",0
  12631.         even
  12632. sfx_empty:    dc.b    " ",0
  12633.         even
  12634. sfx_c_1:    dc.b    "1",0
  12635.         even
  12636. sfx_c_2:    dc.b    "2",0
  12637.         even
  12638. sfx_c_3:    dc.b    "3",0
  12639.         even
  12640. sfx_c_4:    dc.b    "4",0
  12641.         even
  12642. sfx_volume:    dc.b    "Volume",0
  12643.         even
  12644.  
  12645. channel_x    =132
  12646. channel_y    =82+8
  12647. audio_x        =122
  12648. audio_y        =38
  12649.  
  12650. sfx_slider_h_tags:
  12651.         dc.l    GTSL_Level,0
  12652.         dc.l    GTSL_Max,60
  12653.         dc.l    GTSL_Min,1
  12654.         dc.l    GTSL_LevelPlace,PLACETEXT_RIGHT
  12655.         dc.l    GTSL_Justification,GTJ_LEFT
  12656.         dc.l    GTSL_MaxLevelLen,3
  12657.         dc.l    GTSL_LevelFormat,level_format
  12658.         dc.l    PGA_Freedom,LORIENT_HORIZ
  12659.         dc.l    TAG_END,0
  12660.  
  12661. sfx_gadgets:    dc.w    audio_x,audio_y-12+8
  12662.         dc.l    PLACETEXT_LEFT
  12663.         dc.l    sfx_audio
  12664.         dc.w    0
  12665.         dc.w    5                ;checkbox_kind!
  12666.         dc.l    alter_tags_checkbox
  12667.         dc.l    snd_master
  12668.         dc.l    sfx_g_audio
  12669.  
  12670.         dc.w    audio_x+170,audio_y-5-10+8
  12671.         dc.l    PLACETEXT_RIGHT
  12672.         dc.l    sfx_quality
  12673.         dc.w    1
  12674.         dc.w    1                ;mx_kind!
  12675.         dc.l    mx_tags
  12676.         dc.l    sfx_quality_txt
  12677.         dc.l    snd_quality
  12678.         dc.l    sfx_g_quality
  12679.  
  12680.         dc.w    channel_x+30*3,channel_y
  12681.         dc.l    PLACETEXT_RIGHT
  12682.         dc.l    sfx_empty
  12683.         dc.w    5
  12684.         dc.w    5                ;checkbox_kind!
  12685.         dc.l    alter_tags_checkbox
  12686.         dc.l    snd_chnlIV
  12687.         dc.l    sfx_g_c_4
  12688.  
  12689.         dc.w    channel_x+30*2,channel_y
  12690.         dc.l    PLACETEXT_RIGHT
  12691.         dc.l    sfx_empty
  12692.         dc.w    4
  12693.         dc.w    5                ;checkbox_kind!
  12694.         dc.l    alter_tags_checkbox
  12695.         dc.l    snd_chnlIII
  12696.         dc.l    sfx_g_c_3
  12697.  
  12698.         dc.w    channel_x+30,channel_y
  12699.         dc.l    PLACETEXT_RIGHT
  12700.         dc.l    sfx_empty
  12701.         dc.w    3
  12702.         dc.w    5                ;checkbox_kind!
  12703.         dc.l    alter_tags_checkbox
  12704.         dc.l    snd_chnlII
  12705.         dc.l    sfx_g_c_2
  12706.  
  12707.         dc.w    channel_x,channel_y
  12708.         dc.l    PLACETEXT_RIGHT
  12709.         dc.l    sfx_empty
  12710.         dc.w    2
  12711.         dc.w    5                ;checkbox_kind!
  12712.         dc.l    alter_tags_checkbox
  12713.         dc.l    snd_chnlI
  12714.         dc.l    sfx_g_c_1
  12715.  
  12716.         dc.w    161,117+5
  12717.         dc.l    PLACETEXT_IN
  12718.         dc.l    ahi_title
  12719.         dc.w    6
  12720.         dc.w    0                ;button_kind!
  12721.         dc.w    60,14
  12722.         dc.l    sfx_g_ahi_mode
  12723.  
  12724.         dc.w    64,164
  12725.         dc.l    PLACETEXT_LEFT
  12726.         dc.l    sfx_y
  12727.         dc.w    7
  12728.         dc.w    4                ;slider_kind!
  12729.         dc.w    250,10
  12730.         dc.l    sfx_slider_h_tags
  12731.         dc.l    60
  12732.         dc.l    refresh_scanline
  12733.         dc.l    sfx_g_y_hz
  12734.  
  12735.         dc.w    90,41+8
  12736.         dc.l    PLACETEXT_LEFT
  12737.         dc.l    sfx_volume
  12738.         dc.w    8
  12739.         dc.w    4                ;slider_kind!
  12740.         dc.w    84,10
  12741.         dc.l    sfx_slider_h_tags
  12742.         dc.l    16
  12743.         dc.l    sfx_volume_value
  12744.         dc.l    sfx_g_volume
  12745.  
  12746.         dc.l    0
  12747.  
  12748. sfx_ahi_text:    dc.b    1
  12749.         dc.b    0
  12750.         dc.b    0
  12751.         dc.b    0
  12752.         dc.w    0
  12753.         dc.w    116+17+5
  12754.         dc.l    font_attr
  12755. sfx_ahi_txt:    dc.l    0
  12756.         dc.l    0
  12757.  
  12758. chnl_num_x    =channel_x+10
  12759. chnl_num_y    =channel_y-9
  12760.  
  12761. sfx_c_1_text:    dc.b    1
  12762.         dc.b    0
  12763.         dc.b    0
  12764.         dc.b    0
  12765.         dc.w    chnl_num_x
  12766.         dc.w    chnl_num_y
  12767.         dc.l    font_attr
  12768.         dc.l    sfx_c_1
  12769.         dc.l    sfx_c_2_text
  12770.  
  12771. sfx_c_2_text:    dc.b    1
  12772.         dc.b    0
  12773.         dc.b    0
  12774.         dc.b    0
  12775.         dc.w    chnl_num_x+30
  12776.         dc.w    chnl_num_y
  12777.         dc.l    font_attr
  12778.         dc.l    sfx_c_2
  12779.         dc.l    sfx_c_3_text
  12780.  
  12781. sfx_c_3_text:    dc.b    1
  12782.         dc.b    0
  12783.         dc.b    0
  12784.         dc.b    0
  12785.         dc.w    chnl_num_x+30*2
  12786.         dc.w    chnl_num_y
  12787.         dc.l    font_attr
  12788.         dc.l    sfx_c_3
  12789.         dc.l    sfx_c_4_text
  12790.  
  12791. sfx_c_4_text:    dc.b    1
  12792.         dc.b    0
  12793.         dc.b    0
  12794.         dc.b    0
  12795.         dc.w    chnl_num_x+30*3
  12796.         dc.w    chnl_num_y
  12797.         dc.l    font_attr
  12798.         dc.l    sfx_c_4
  12799.         dc.l    sfx_c_5_text
  12800.  
  12801. sfx_c_5_text:    dc.b    2
  12802.         dc.b    0
  12803.         dc.b    0
  12804.         dc.b    0
  12805.         dc.w    164
  12806.         dc.w    109
  12807.         dc.l    font_attr
  12808.         dc.l    sfx_ahi_mode
  12809.         dc.l    sfx_c_6_text
  12810.  
  12811. sfx_c_6_text:    dc.b    2
  12812.         dc.b    0
  12813.         dc.b    0
  12814.         dc.b    0
  12815.         dc.w    164
  12816.         dc.w    60+8
  12817.         dc.l    font_attr
  12818.         dc.l    sfx_channels
  12819.         dc.l    sfx_c_7_text
  12820.  
  12821. sfx_c_7_text:    dc.b    2
  12822.         dc.b    0
  12823.         dc.b    0
  12824.         dc.b    0
  12825.         dc.w    96
  12826.         dc.w    9+8
  12827.         dc.l    font_attr
  12828.         dc.l    sfx_master
  12829.         dc.l    sfx_c_8_text
  12830.  
  12831. sfx_c_8_text:    dc.b    2
  12832.         dc.b    0
  12833.         dc.b    0
  12834.         dc.b    0
  12835.         dc.w    274
  12836.         dc.w    9+8
  12837.         dc.l    font_attr
  12838.         dc.l    sfx_audio
  12839.         dc.l    sfx_c_9_text
  12840.  
  12841. sfx_c_9_text:    dc.b    2
  12842.         dc.b    0
  12843.         dc.b    0
  12844.         dc.b    0
  12845.         dc.w    164
  12846.         dc.w    109+34+9
  12847.         dc.l    font_attr
  12848.         dc.l    sfx_variables
  12849.         dc.l    0
  12850.  
  12851. sfx_ahi_mode:    dc.b    "AHI mode",0
  12852.         even
  12853. sfx_channels:    dc.b    "Channels",0
  12854.         even
  12855. sfx_master:    dc.b    "Master",0
  12856.         even
  12857. sfx_variables:    dc.b    "Variables",0
  12858.         even
  12859.  
  12860. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  12861. ;        gfx gadgets
  12862. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  12863.  
  12864. gfx_g_aga_mode:    dc.l    0
  12865. gfx_g_driver:    dc.l    0
  12866. gfx_g_frame_skip:
  12867.         dc.l    0
  12868. gfx_g_mode:    dc.l    0
  12869. gfx_g_obtain:    dc.l    0
  12870. gfx_g_scaling:    dc.l    0
  12871. gfx_g_scanline_x:
  12872.         dc.l    0
  12873. gfx_g_select:    dc.l    0
  12874. gfx_g_colour_load:
  12875.         dc.l    0
  12876.  
  12877. aga_mode_txt_list:
  12878.         dc.l    gfx_pal
  12879.         dc.l    gfx_ntsc
  12880.         dc.l    0
  12881.  
  12882. drivers_txt_list:
  12883.         dc.l    gfx_aga
  12884.         dc.l    gfx_screen
  12885.         dc.l    gfx_window
  12886.         dc.l    0
  12887.  
  12888. scaling_txt_list:
  12889.         dc.l    gfx_solid
  12890.         dc.l    gfx_scalable
  12891.         dc.l    0
  12892.  
  12893. update_txt_list:dc.l    gfx_full
  12894.         dc.l    gfx_x_153
  12895.         dc.l    0
  12896.  
  12897. gfx_solid:    dc.b    "Solid",0
  12898.         even
  12899. gfx_scalable:    dc.b    "Scalable",0
  12900.         even
  12901. gfx_pal:    dc.b    "PAL",0
  12902.         even
  12903. gfx_ntsc:    dc.b    "NTSC",0
  12904.         even
  12905. gfx_full:    dc.b    "Full",0
  12906.         even
  12907. gfx_x_153:    dc.b    "x/153",0
  12908.         even
  12909. gfx_aga:    dc.b    "AGA",0
  12910.         even
  12911. gfx_screen:    dc.b    "Screen",0
  12912.         even
  12913. gfx_window:    dc.b    "Window",0
  12914.         even
  12915. gfx_driver:    dc.b    "Driver",0
  12916.         even
  12917. gfx_scanline:    dc.b    "x",0
  12918.         even
  12919. gfx_mode:    dc.b    "Mode",0
  12920.         even
  12921. gfx_select:    dc.b    "Select",0
  12922.         even
  12923. gfx_obtain:    dc.b    "Obtain",0
  12924.         even
  12925. gfx_load:    dc.b    "Load",0
  12926.         even
  12927. gfx_frame_skip:    dc.b    "Frame skip",0
  12928.         even
  12929. gfx_empty:    dc.b    " ",0
  12930.  
  12931. slider_h_tags:    dc.l    GTSL_Level,0
  12932.         dc.l    GTSL_Max,153
  12933.         dc.l    GTSL_Min,0
  12934.         dc.l    GTSL_LevelPlace,PLACETEXT_RIGHT
  12935.         dc.l    GTSL_Justification,GTJ_LEFT
  12936.         dc.l    GTSL_MaxLevelLen,3
  12937.         dc.l    GTSL_LevelFormat,level_format
  12938.         dc.l    PGA_Freedom,LORIENT_HORIZ
  12939.         dc.l    TAG_END,0
  12940.  
  12941. level_format:    dc.b    "%ld",0
  12942.         even
  12943.  
  12944. driver_x    =198
  12945. driver_y    =20
  12946.  
  12947. gfx_gadgets:    dc.w    driver_x+53,driver_y-5
  12948.         dc.l    PLACETEXT_RIGHT
  12949.         dc.l    gfx_empty
  12950.         dc.w    5
  12951.         dc.w    1                ;mx_kind!
  12952.         dc.l    mx_tags
  12953.         dc.l    aga_mode_txt_list
  12954.         dc.l    aga_mode
  12955.         dc.l    gfx_g_aga_mode
  12956.  
  12957.         dc.w    driver_x,driver_y
  12958.         dc.l    PLACETEXT_RIGHT
  12959.         dc.l    gfx_driver
  12960.         dc.w    0
  12961.         dc.w    1                ;mx_kind!
  12962.         dc.l    mx_special_tags
  12963.         dc.l    drivers_txt_list
  12964.         dc.l    old_render
  12965.         dc.l    gfx_g_driver
  12966.  
  12967.         dc.w    driver_x+72,driver_y+31
  12968.         dc.l    PLACETEXT_RIGHT
  12969.         dc.l    gfx_empty
  12970.         dc.w    1
  12971.         dc.w    1                ;mx_kind!
  12972.         dc.l    mx_tags
  12973.         dc.l    scaling_txt_list
  12974.         dc.l    scaling_status
  12975.         dc.l    gfx_g_scaling
  12976.  
  12977.         dc.w    74,33
  12978.         dc.l    PLACETEXT_RIGHT
  12979.         dc.l    gfx_mode
  12980.         dc.w    2
  12981.         dc.w    1                ;mx_kind!
  12982.         dc.l    mx_tags
  12983.         dc.l    update_txt_list
  12984.         dc.l    old_refresh
  12985.         dc.l    gfx_g_mode
  12986.  
  12987.         dc.w    50,89
  12988.         dc.l    PLACETEXT_LEFT
  12989.         dc.l    gfx_scanline
  12990.         dc.w    3
  12991.         dc.w    4                ;slider_kind!
  12992.         dc.w    130,10
  12993.         dc.l    slider_h_tags
  12994.         dc.l    153
  12995.         dc.l    refresh_scanline
  12996.         dc.l    gfx_g_scanline_x
  12997.  
  12998.         dc.w    driver_x+74,driver_y+16
  12999.         dc.l    PLACETEXT_IN
  13000.         dc.l    gfx_select
  13001.         dc.w    4
  13002.         dc.w    0                ;button_kind!
  13003.         dc.w    60,13
  13004.         dc.l    gfx_g_select
  13005.  
  13006.         dc.w    120,120
  13007.         dc.l    PLACETEXT_IN
  13008.         dc.l    gfx_obtain
  13009.         dc.w    6
  13010.         dc.w    0                ;button_kind!
  13011.         dc.w    61,14
  13012.         dc.l    gfx_g_obtain
  13013.  
  13014.         dc.w    298,89
  13015.         dc.l    PLACETEXT_LEFT
  13016.         dc.l    gfx_frame_skip
  13017.         dc.w    7
  13018.         dc.w    4                ;slider_kind!
  13019.         dc.w    30,10
  13020.         dc.l    slider_h_tags
  13021.         dc.l    16
  13022.         dc.l    frame_update_number
  13023.         dc.l    gfx_g_frame_skip
  13024.  
  13025.         dc.w    190,122
  13026.         dc.l    PLACETEXT_RIGHT
  13027.         dc.l    gfx_load
  13028.         dc.w    8
  13029.         dc.w    5                ;checkbox_kind!
  13030.         dc.l    alter_tags_checkbox
  13031.         dc.l    colour_load_status
  13032.         dc.l    gfx_g_colour_load
  13033.  
  13034.         dc.l    0
  13035.  
  13036. gfx_txt_1:    dc.b    2
  13037.         dc.b    0
  13038.         dc.b    0
  13039.         dc.b    0
  13040.         dc.w    124
  13041.         dc.w    2
  13042.         dc.l    font_attr
  13043.         dc.l    gfx_emulation
  13044.         dc.l    gfx_txt_2
  13045.  
  13046. gfx_txt_2:    dc.b    2
  13047.         dc.b    0
  13048.         dc.b    0
  13049.         dc.b    0
  13050.         dc.w    154
  13051.         dc.w    77
  13052.         dc.l    font_attr
  13053.         dc.l    gfx_variables
  13054.         dc.l    gfx_txt_3
  13055.  
  13056. gfx_txt_3:    dc.b    2
  13057.         dc.b    0
  13058.         dc.b    0
  13059.         dc.b    0
  13060.         dc.w    158
  13061.         dc.w    106
  13062.         dc.l    font_attr
  13063.         dc.l    gfx_colours
  13064.         dc.l    0
  13065.  
  13066. gfx_emulation:    dc.b    "Graphics emulation",0
  13067.         even
  13068. gfx_variables:    dc.b    "Variables",0
  13069.         even
  13070. gfx_colours:    dc.b    "Colours",0
  13071.         even
  13072.  
  13073. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13074. ;        about texts
  13075. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13076.  
  13077. about_text_1:    dc.b    1
  13078.         dc.b    0
  13079.         dc.b    0
  13080.         dc.b    0
  13081.         dc.w    0                ;x is computed.
  13082.         dc.w    173
  13083.         dc.l    font_attr
  13084.         dc.l    about_txt_1
  13085.         dc.l    0
  13086.  
  13087. about_text_2:    dc.b    1
  13088.         dc.b    0
  13089.         dc.b    0
  13090.         dc.b    0
  13091.         dc.w    0                ;x is computed.
  13092.         dc.w    173+8
  13093.         dc.l    font_attr
  13094.         dc.l    about_txt_2
  13095.         dc.l    0
  13096.  
  13097. about_txt_1:    dc.b    "WZONKA-LAD 1.03.00"
  13098.  
  13099.         dc.b    " (680x0 / "
  13100.         IFEQ    Z80_MODE
  13101.         dc.b    "FULL Z80)",0
  13102.         ENDIF
  13103.         IFLT    Z80_MODE
  13104.         dc.b    "CRIPPLED Z80)",0
  13105.         ENDIF
  13106.         IFGT    Z80_MODE
  13107.         dc.b    "CRIPPLED HARDWARE)",0
  13108.         ENDIF
  13109.  
  13110. about_txt_2:    dc.b    "FREEWARE VERSION!",0
  13111.         ds.b    64
  13112.         even
  13113.  
  13114. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13115. ;        info texts
  13116. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13117.  
  13118. info_y        =149
  13119.  
  13120. info_text_1:    dc.b    1
  13121.         dc.b    0
  13122.         dc.b    0
  13123.         dc.b    0
  13124.         dc.w    0                ;x is computed.
  13125.         dc.w    info_y
  13126.         dc.l    font_attr
  13127.         dc.l    info_txt_1
  13128.         dc.l    0
  13129.  
  13130. info_text_2:    dc.b    1
  13131.         dc.b    0
  13132.         dc.b    0
  13133.         dc.b    0
  13134.         dc.w    0                ;x is computed.
  13135.         dc.w    info_y+8
  13136.         dc.l    font_attr
  13137.         dc.l    info_txt_2
  13138.         dc.l    0
  13139.  
  13140. info_text_3:    dc.b    1
  13141.         dc.b    0
  13142.         dc.b    0
  13143.         dc.b    0
  13144.         dc.w    0                ;x is computed.
  13145.         dc.w    info_y+8*2
  13146.         dc.l    font_attr
  13147. rom_ptr:    dc.l    info_txt_na
  13148.         dc.l    0
  13149.  
  13150. info_text_4:    dc.b    1
  13151.         dc.b    0
  13152.         dc.b    0
  13153.         dc.b    0
  13154.         dc.w    0                ;x is computed.
  13155.         dc.w    info_y+8*3
  13156.         dc.l    font_attr
  13157. ram_ptr:    dc.l    info_txt_na
  13158.         dc.l    0
  13159.  
  13160. info_text_5:    dc.b    1
  13161.         dc.b    0
  13162.         dc.b    0
  13163.         dc.b    0
  13164.         dc.w    0                ;x is computed.
  13165.         dc.w    info_y+8*4
  13166.         dc.l    font_attr
  13167. battery_ptr:    dc.l    info_txt_na
  13168.         dc.l    0
  13169.  
  13170. info_txt_1:    dc.b    "N/A",0
  13171.         ds.b    32
  13172.         even
  13173. info_txt_2:    dc.b    "N/A",0
  13174.         ds.b    64
  13175.         even
  13176. info_txt_na:    dc.b    "N/A",0
  13177.         even
  13178.  
  13179. info_txt_n_btt:    dc.b    "NO BATTERY FOUND",0
  13180.         even
  13181. info_txt_y_btt:    dc.b    "BATTERY LOCATED",0
  13182.         even
  13183.  
  13184. info_text_list:    dc.l    info_text_1
  13185.         dc.l    info_text_2
  13186.         dc.l    info_text_3
  13187.         dc.l    info_text_4
  13188.         dc.l    info_text_5
  13189.  
  13190. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13191. ;        sanpshotting variables
  13192. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13193.  
  13194. snapshot_area:    dc.l    0
  13195. snapshot_size:    dc.l    0
  13196.  
  13197. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13198. ;        bitmaps
  13199. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13200.  
  13201. info_map_attr:    dc.l    0
  13202. about_map_attr:    dc.l    0
  13203. back_pattern_map_attr:
  13204.         dc.l    0
  13205. wzonka_map_attr:dc.l    0
  13206.  
  13207. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13208. ;        ahi variables, lists and names
  13209. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13210.  
  13211. snd_master:    dc.b    0
  13212. snd_chnlI:    dc.b    0
  13213. snd_chnlII:    dc.b    0
  13214. snd_chnlIII:    dc.b    0
  13215. snd_chnlIV:    dc.b    0
  13216. snd_quality:    dc.b    0
  13217.         even
  13218.  
  13219. ahi_name:    dc.b    "ahi.device",0
  13220.         even
  13221.  
  13222. ahi_port:    dc.l    0
  13223. ahi_ior:    dc.l    0
  13224. ahi_device:    dc.l    0
  13225. ahi_audio_ctrl:    dc.l    0
  13226. ahi_request:    dc.l    0
  13227. ahi_base:    dc.l    0
  13228.  
  13229. ahi_alloc_tags:    dc.l    AHIA_AudioID,AHI_DEFAULT_ID
  13230.         dc.l    AHIA_MixFreq,4410
  13231.         dc.l    AHIA_Channels,4
  13232.         dc.l    AHIA_Sounds,4
  13233.         dc.l    TAG_END,0
  13234.  
  13235. ahi_requ_tags:    dc.l    AHIR_Window,0
  13236.         dc.l    AHIR_InitialMixFreq,4410
  13237.         dc.l    AHIR_InitialAudioID,AHI_DEFAULT_ID
  13238.         dc.l    AHIR_TitleText,ahi_title
  13239.         dc.l    AHIR_DoMixFreq,TRUE
  13240.         dc.l    TAG_END,0
  13241.  
  13242. ahi_ctrl_tags_I:dc.l    AHIC_Play,TRUE
  13243.         dc.l    TAG_END,0
  13244.  
  13245. ahi_attrs_tags:    dc.l    AHIDB_Name,0
  13246.         dc.l    AHIDB_BufferLen,128
  13247.         dc.l    TAG_END,0
  13248.  
  13249. ahi_mode_txt:    dc.l    0
  13250. ahi_mix_freq:    dc.l    4410
  13251. ahi_mode_id:    dc.l    0
  13252.  
  13253. smpl_info_I:    dc.l    0
  13254. smpl_info_II:    dc.l    0
  13255. smpl_info_III:    dc.l    0
  13256. smpl_info_IV:    dc.l    0
  13257.  
  13258. ahi_title:    dc.b    "Select",0
  13259.         even
  13260.  
  13261. smpl_bn_1:    dc.b    $80
  13262.         dc.b    $7f
  13263.         dc.b    $7f
  13264.         dc.b    $7f
  13265.         dc.b    $7f
  13266.         dc.b    $7f
  13267.         dc.b    $7f
  13268.         dc.b    $7f
  13269.  
  13270. smpl_bn_2:    dc.b    $80
  13271.         dc.b    $80
  13272.         dc.b    $7f
  13273.         dc.b    $7f
  13274.         dc.b    $7f
  13275.         dc.b    $7f
  13276.         dc.b    $7f
  13277.         dc.b    $7f
  13278.  
  13279. smpl_bn_3:    dc.b    $80
  13280.         dc.b    $80
  13281.         dc.b    $80
  13282.         dc.b    $80
  13283.         dc.b    $7f
  13284.         dc.b    $7f
  13285.         dc.b    $7f
  13286.         dc.b    $7f
  13287.  
  13288. smpl_bn_4:    dc.b    $80
  13289.         dc.b    $80
  13290.         dc.b    $80
  13291.         dc.b    $80
  13292.         dc.b    $80
  13293.         dc.b    $80
  13294.         dc.b    $7f
  13295.         dc.b    $7f
  13296.  
  13297. smpl_IV_bn:    incbin    "samples/noise.smpl"
  13298.         incbin    "samples/noise.smpl"
  13299.         incbin    "samples/noise.smpl"
  13300.         incbin    "samples/noise.smpl"
  13301.         even
  13302.  
  13303. smpl_mem_1:    dc.l    0
  13304. smpl_mem_2:    dc.l    0
  13305. smpl_mem_3:    dc.l    0
  13306. smpl_mem_4:    dc.l    0
  13307.  
  13308. smpl_III_mem:    dc.l    0
  13309.  
  13310. sound_routines:    dc.l    sound_I_0
  13311.         dc.l    sound_I_1
  13312.         dc.l    sound_I_2
  13313.         dc.l    sound_I_3
  13314.         dc.l    sound_I_4
  13315.  
  13316.         dc.l    sound_II_1
  13317.         dc.l    sound_II_2
  13318.         dc.l    sound_II_3
  13319.         dc.l    sound_II_4
  13320.  
  13321.         dc.l    sound_III_0
  13322.         dc.l    sound_III_1
  13323.         dc.l    sound_III_2
  13324.         dc.l    sound_III_3
  13325.         dc.l    sound_III_4
  13326.  
  13327.         dc.l    sound_IV_1
  13328.         dc.l    sound_IV_2
  13329.         dc.l    sound_IV_3
  13330.         dc.l    sound_IV_4
  13331.  
  13332.         dc.l    sound_V_0
  13333.         dc.l    sound_V_1
  13334.         dc.l    sound_V_2
  13335.  
  13336.         dc.l    copy_snd_data
  13337.  
  13338. sound_routines_for_y_driver:
  13339.         dc.l    gb_mem_wr
  13340.         dc.l    gb_mem_wr
  13341.         dc.l    gb_mem_wr
  13342.         dc.l    gb_mem_wr
  13343.         dc.l    gb_mem_wr
  13344.  
  13345.         dc.l    gb_mem_wr
  13346.         dc.l    gb_mem_wr
  13347.         dc.l    gb_mem_wr
  13348.         dc.l    gb_mem_wr
  13349.  
  13350.         dc.l    gb_mem_wr
  13351.         dc.l    gb_mem_wr
  13352.         dc.l    gb_mem_wr
  13353.         dc.l    gb_mem_wr
  13354.         dc.l    gb_mem_wr
  13355.  
  13356.         dc.l    gb_mem_wr
  13357.         dc.l    gb_mem_wr
  13358.         dc.l    gb_mem_wr
  13359.         dc.l    gb_mem_wr
  13360.  
  13361.         dc.l    gb_mem_wr
  13362.         dc.l    gb_mem_wr
  13363.         dc.l    gb_mem_wr
  13364.  
  13365.         dc.l    gb_mem_wr
  13366.  
  13367. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13368. ;        rom and ram size tables
  13369. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13370.  
  13371. gb_mem_jumps:    dc.l    0
  13372.  
  13373. rom_table:    dc.l    rom_kb256,rom_kb512,rom_mb1,rom_mb2,rom_mb4,rom_mb8
  13374.         dc.l    rom_mb16,rom_mb32,rom_mb64,rom_illegal
  13375.         dc.l    rom_mb9,rom_mb10,rom_mb12
  13376.  
  13377. ram_table:    dc.l    ram_kb0,ram_kb16,ram_kb64,ram_kb256,ram_mb1
  13378.         dc.l    ram_illegal
  13379.  
  13380. mapper_table:    dc.l    map_0,map_1,map_2,map_3,map_inv,map_5,map_6
  13381.         dc.l    map_inv,map_8,map_9
  13382.         dc.l    map_inv ;a.
  13383.         dc.l    map_b   ;b.
  13384.         dc.l    map_c   ;c.
  13385.         dc.l    map_d   ;d.
  13386.         dc.l    map_inv ;e.
  13387.         dc.l    map_f   ;f.
  13388.         dc.l    map_10  ;10.
  13389.         dc.l    map_11  ;11.
  13390.         dc.l    map_12  ;12.
  13391.         dc.l    map_13  ;13.
  13392.         dc.l    map_inv ;14.
  13393.         dc.l    map_15  ;15.
  13394.         dc.l    map_16  ;16.
  13395.         dc.l    map_17  ;17.
  13396.         dc.l    map_inv ;18.
  13397.         dc.l    map_19  ;19.
  13398.         dc.l    map_1a  ;1a.
  13399.         dc.l    map_1b  ;1b.
  13400.         dc.l    map_1c  ;1c.
  13401.         dc.l    map_1d  ;1d.
  13402.         dc.l    map_1e  ;1e.
  13403.         dc.l    map_1f  ;1f.
  13404.  
  13405. map_0:        dc.b    "ROM ONLY",0
  13406.         even
  13407. map_1:        dc.b    "ROM+MBC1",0
  13408.         even
  13409. map_2:        dc.b    "ROM+MBC1+RAM",0
  13410.         even
  13411. map_3:        dc.b    "ROM+MBC1+RAM+BATTERY",0
  13412.         even
  13413. map_5:        dc.b    "ROM+MBC2",0
  13414.         even
  13415. map_6:        dc.b    "ROM+MBC2+BATTERY",0
  13416.         even
  13417. map_8:        dc.b    "ROM+RAM",0
  13418.         even
  13419. map_9:        dc.b    "ROM+RAM+BATTERY",0
  13420.         even
  13421. map_b:        dc.b    "ROM+MMM01 (EMAIL ME!)",0
  13422.         even
  13423. map_c:        dc.b    "ROM+MMM01+SRAM (EMAIL ME!)",0
  13424.         even
  13425. map_d:        dc.b    "ROM+MMM01+SRAM+BATTERY (EMAIL ME!)",0
  13426.         even
  13427. map_f:        dc.b    "ROM+MBC3+TIMER+BATTERY",0
  13428.         even
  13429. map_10:        dc.b    "ROM+MBC3+TIMER+RAM+BATTERY",0
  13430.         even
  13431. map_11:        dc.b    "ROM+MBC3",0
  13432.         even
  13433. map_12:        dc.b    "ROM+MBC3+RAM",0
  13434.         even
  13435. map_13:        dc.b    "ROM+MBC3+RAM+BATTERY",0
  13436.         even
  13437. map_15:        dc.b    "ROM+MBC4 (EMAIL ME!)",0
  13438.         even
  13439. map_16:        dc.b    "ROM+MBC4+RAM (EMAIL ME!)",0
  13440.         even
  13441. map_17:        dc.b    "ROM+MBC4+RAM+BATTERY (EMAIL ME!)",0
  13442.         even
  13443. map_19:        dc.b    "ROM+MBC5",0
  13444.         even
  13445. map_1a:        dc.b    "ROM+MBC5+RAM",0
  13446.         even
  13447. map_1b:        dc.b    "ROM+MBC5+RAM+BATTERY",0
  13448.         even
  13449. map_1c:        dc.b    "ROM+MBC5+RUMBLE",0
  13450.         even
  13451. map_1d:        dc.b    "ROM+MBC5+RUMBLE+SRAM",0
  13452.         even
  13453. map_1e:        dc.b    "ROM+MBC5+RUMBLE+SRAM+BATTERY",0
  13454.         even
  13455. map_1f:        dc.b    "POCKET CAMERA (EMAIL ME!)",0
  13456.         even
  13457. map_fd:        dc.b    "BANDAI TAMA5 (EMAIL ME!)",0
  13458.         even
  13459. map_fe:        dc.b    "ROM+HUC3+RAM+BATTERY (EMAIL ME!)",0
  13460.         even
  13461. map_ff:        dc.b    "ROM+HUC1+RAM+BATTERY",0
  13462.         even
  13463. map_inv:    dc.b    "UNKNOWN CARTRIDGE TYPE! (EMAIL ME!)",0
  13464.         even
  13465.  
  13466. ram_kb0:    dc.b    "NO EXTERNAL RAM",0
  13467.         even
  13468. ram_kb16:    dc.b    "2KB OF EXTERNAL RAM",0
  13469.         even
  13470. ram_kb64:    dc.b    "8KB OF EXTERNAL RAM",0
  13471.         even
  13472. ram_kb256:    dc.b    "32KB OF EXTERNAL RAM",0
  13473.         even
  13474. ram_mb1:    dc.b    "128KB OF EXTERNAL RAM",0
  13475.         even
  13476. ram_illegal:    dc.b    "UNKNOWN AMOUNT OF RAM BANKS!",0
  13477.         even
  13478. rom_kb256:    dc.b    "2 ROM BANKS",0
  13479.         even
  13480. rom_kb512:    dc.b    "4 ROM BANKS",0
  13481.         even
  13482. rom_mb1:    dc.b    "8 ROM BANKS",0
  13483.         even
  13484. rom_mb2:    dc.b    "16 ROM BANKS",0
  13485.         even
  13486. rom_mb4:    dc.b    "32 ROM BANKS",0
  13487.         even
  13488. rom_mb8:    dc.b    "64 ROM BANKS",0
  13489.         even
  13490. rom_mb9:    dc.b    "72 ROM BANKS",0
  13491.         even
  13492. rom_mb10:    dc.b    "80 ROM BANKS",0
  13493.         even
  13494. rom_mb12:    dc.b    "96 ROM BANKS",0
  13495.         even
  13496. rom_mb16:    dc.b    "128 ROM BANKS",0
  13497.         even
  13498. rom_mb32:    dc.b    "256 ROM BANKS",0
  13499.         even
  13500. rom_mb64:    dc.b    "512 ROM BANKS",0
  13501.         even
  13502. rom_illegal:    dc.b    "UNKNOWN AMOUNT OF ROM BANKS!",0
  13503.         even
  13504.  
  13505. rom_banks_list:    dc.l    2-1,4-1,8-1,16-1,32-1,64-1,128-1,256-1,512-1
  13506.         dc.l    0,9-1,10-1,12-1
  13507.         even
  13508.  
  13509. ram_banks_list:    dc.b    0,1,1,4,16
  13510.         even
  13511. ram_banks_mask_list:
  13512.         dc.b    0,0,0,3,15
  13513.         even
  13514.  
  13515. cartridge_name:    ds.b    32
  13516.         even
  13517.  
  13518. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13519. ;        preferences file
  13520. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13521.  
  13522. prefs_file_name:dc.b    "ENVARC:Wzonka-Lad.prefs",0
  13523.         even
  13524. prefs_file:    dc.l    0
  13525. prefs_file_rom:    dc.l    0
  13526.  
  13527. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13528. ;        the window titles
  13529. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13530.  
  13531. info_win_txt:    dc.b    "ROM image information",0
  13532.         even
  13533. about_win_txt:    dc.b    "About Wzonka-Lad",0
  13534.         even
  13535. prefs_win_txt:    dc.b    "Preferences",0
  13536.         even
  13537. sfx_win_txt:    dc.b    "Sound settings",0
  13538.         even
  13539. gfx_win_txt:    dc.b    "Visual settings",0
  13540.         even
  13541. misc_win_txt:    dc.b    "Misc settings",0
  13542.         even
  13543.  
  13544. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13545. ;        the version string
  13546. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13547.  
  13548. version_data:    dc.b    "$VER: Wzonka-Lad 1.03.00"
  13549.         dc.b    " (03.01.2004)",0
  13550.         even
  13551.  
  13552. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13553. ;        list header
  13554. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13555.  
  13556. joy_label_list:    dc.l    0
  13557. xpk_label_list:    dc.l    0
  13558. gg_label_list:    dc.l    0
  13559. gg_dummy_item:    dc.l    0
  13560.  
  13561. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13562. ;        bevel box lists
  13563. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13564.  
  13565. menu_bevel_list:dc.w    24,29-14,76,54+15
  13566.         dc.w    24+76+12,29-14,76,39
  13567.         dc.w    24+76*2+12*2,29-14,76,54+15
  13568.         dc.w    24,80+7,76*3+12*2,14
  13569.         dc.w    0
  13570.  
  13571. sfx_bevel_list:    dc.w    28,17+8,326-122-22,41
  13572.         dc.w    28+326-122,17+8,122,41
  13573.         dc.w    100,68+8,182,31
  13574.         dc.w    28,68+39+10,326,33
  13575.         dc.w    28,68+39+10+33+10,326,19
  13576.         dc.w    0
  13577.  
  13578. prefs_bevel_list:
  13579.         dc.w    26,10,326,66
  13580.         dc.w    26,86,174,64
  13581.         dc.w    26,160,174,23
  13582.         dc.w    227,86,125,58
  13583.         dc.w    227,154,125,29
  13584.         dc.w    0
  13585.  
  13586. gfx_bevel_list:    dc.w    20,10,334,65
  13587.         dc.w    20,85,334,19
  13588.         dc.w    20,114,334,69
  13589.         dc.w    0
  13590.  
  13591. misc_bevel_list:dc.w    85,misc_g_y-6,205,49
  13592.         dc.w    35,misc_g_y+53,305,78
  13593.         dc.w    0
  13594.  
  13595. bevel_box_tags:    dc.l    GT_VisualInfo,0
  13596.         dc.l    GTBB_Recessed,TRUE
  13597.         dc.l    GTBB_FrameType,BBFT_BUTTON
  13598.         dc.l    TAG_END,0
  13599.  
  13600. bevel_box_tagz:    dc.l    GT_VisualInfo,0
  13601.         dc.l    GTBB_FrameType,BBFT_BUTTON
  13602.         dc.l    TAG_END,0
  13603.  
  13604. button_gadget_underscore_tag:
  13605.         dc.l    GT_Underscore, '_'
  13606.         dc.l    TAG_END,0
  13607.  
  13608. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13609. ;        window graphics
  13610. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13611.  
  13612.         cnop    0,4
  13613. back_pattern_bn:incbin    "windows/pattern.bn"
  13614.         cnop    0,4
  13615. about_map_rle:    incbin    "windows/about.rle"
  13616.         cnop    0,4
  13617. info_map_rle:    incbin    "windows/info.rle"
  13618.         cnop    0,4
  13619.  
  13620. about_map:    dc.l    0
  13621. info_map:    dc.l    0
  13622. back_pattern_map:
  13623.         dc.l    0
  13624. wzonka_map:    dc.l    0
  13625.  
  13626. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13627. ;        message port
  13628. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13629.  
  13630. message_port:    dc.l    0
  13631. message_port_colour_editor:
  13632.         dc.l    0
  13633. message_port_name:
  13634.         dc.b    "Wzonka-Lad Port",0
  13635.         even
  13636. message_port_colour_editor_name:
  13637.         dc.b    "Wzonka-Lad Palette Editor Port",0
  13638.         even
  13639.  
  13640. obtain_gadget_status:
  13641.         dc.l    0                ;0 = on / 1 = off.
  13642. colour_message:    dc.l    0
  13643. colour_message_name:
  13644.         dc.l    0
  13645.  
  13646. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13647. ;        read pixel array
  13648. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13649.  
  13650. gfx_game_still_array:
  13651.         dc.l    0
  13652. gfx_game_still_map_attr:
  13653.         dc.l    0
  13654. gfx_game_still_rast_port:
  13655.         dc.l    0
  13656.  
  13657. gfx_game_still_tmp_array:
  13658.         dc.l    0
  13659. gfx_game_still_tmp_map_attr:
  13660.         dc.l    0
  13661. gfx_game_still_tmp_rast_port:
  13662.         dc.l    0
  13663.  
  13664. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13665. ;        obtain pens
  13666. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13667.  
  13668. obtain_pens_tag_list:
  13669.         dc.l    OBP_Precision,PRECISION_IMAGE
  13670.         dc.l    OBP_FailIfBad,FALSE
  13671.         dc.l    TAG_END,0
  13672.  
  13673. gameboy_colours:incbin    "data/gameboy_colours.pal"
  13674.         even
  13675.  
  13676. gameboy_colours_conversion_table:
  13677.         ds.b    16
  13678.  
  13679. pen_conversion_table:
  13680.         dc.l    0
  13681. pen_list:    ds.b    8
  13682. pen_storage_list:
  13683.         ds.b    8
  13684.  
  13685. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13686. ;        the 20 recent menu items for menu window
  13687. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13688.  
  13689.         include    "menu_data_recent.i"
  13690.  
  13691. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13692. ;        the favourite menu items for menu window
  13693. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13694.  
  13695.         include    "menu_data_favourite.i"
  13696.  
  13697. menu_favo_nf:    dc.l    0                ;menu name field.
  13698. menu_favo_fl:    dc.l    0                ;menu input file.
  13699.  
  13700. menu_favo_nm:    dc.b    "PROGDIR:favourites/favourites.list",0
  13701.         even
  13702.  
  13703. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13704. ;        the keyboard handler
  13705. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13706.  
  13707. buttons_byte:    dc.b    $cf
  13708. directions_byte:dc.b    $cf
  13709. buttons_byte_o:    dc.b    $cf
  13710. directions_byte_o:
  13711.         dc.b    $cf
  13712.         even
  13713.  
  13714. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13715. ;        ram lists
  13716. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13717.  
  13718. ram_size_list:    dc.l    8192                ;actually 0kb.
  13719.         dc.l    8192                ;         2  .
  13720.         dc.l    8192
  13721.         dc.l    32768
  13722.         dc.l    131072
  13723.         dc.l    131072
  13724.         dc.l    131072
  13725.         dc.l    131072
  13726.  
  13727. mapper_list:    dc.l    mapper_na
  13728.         dc.l    mapper_mbc1
  13729.         dc.l    mapper_mbc1_ram
  13730.         dc.l    mapper_mbc1_ram_battery
  13731.         dc.l    mapper_na            ;invalid entry.
  13732.         dc.l    mapper_mbc2
  13733.         dc.l    mapper_mbc2_battery
  13734.         dc.l    mapper_na            ;invalid entry.
  13735.         dc.l    mapper_ram
  13736.         dc.l    mapper_ram_battery
  13737.  
  13738.         dc.l    mapper_na            ;a.
  13739.         dc.l    mapper_na
  13740.         dc.l    mapper_na
  13741.         dc.l    mapper_na
  13742.         dc.l    mapper_na
  13743.         dc.l    mapper_mbc3_timer_battery    ;f.
  13744.  
  13745.         dc.l    mapper_mbc3_timer_ram_battery    ;10.
  13746.         dc.l    mapper_mbc3            ;11.
  13747.         dc.l    mapper_mbc3_ram            ;12.
  13748.         dc.l    mapper_mbc3_ram_battery        ;13.
  13749.         dc.l    mapper_na
  13750.         dc.l    mapper_na            ;15.
  13751.         dc.l    mapper_na            ;16.
  13752.         dc.l    mapper_na            ;17.
  13753.         dc.l    mapper_na
  13754.  
  13755.         dc.l    mapper_mbc5            ;19.
  13756.         dc.l    mapper_mbc5_ram            ;1a.
  13757.         dc.l    mapper_mbc5_ram_battery        ;1b.
  13758.         dc.l    mapper_mbc5_rumble        ;1c.
  13759.         dc.l    mapper_mbc5_rumble_sram        ;1d.
  13760.         dc.l    mapper_mbc5_rumble_sram_battery    ;1e.
  13761.  
  13762. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13763. ;        ROM+HUC1+RAM (+BATTERY)
  13764. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13765.  
  13766. mapper_huc1_ram:
  13767. mapper_huc1_ram_battery:
  13768.         dc.l    mapper_huc1_0kb_ram
  13769.         dc.l    mapper_huc1_2kb_ram
  13770.         dc.l    mapper_huc1_8kb_ram
  13771.         dc.l    mapper_huc1_32kb_ram
  13772.  
  13773. mapper_huc1_0kb_ram:
  13774.         dc.l    6-1,$2000-1
  13775.         dc.l    rom_write
  13776.         dc.l    mbc1_rom_switch
  13777.         dc.l    mbc1_rom_switch_two_address_lines
  13778.         dc.l    mbc1_rom_mode_select
  13779.         dc.l    gb_mem_wr
  13780.         dc.l    gb_mem_wr
  13781. ;        dc.l    gb_mem_wr_denied
  13782.  
  13783. mapper_huc1_2kb_ram:
  13784.         dc.l    24-1,$800-1
  13785.  
  13786.         dc.l    mbc1_ram_protection
  13787.         dc.l    mbc1_ram_protection
  13788.         dc.l    mbc1_ram_protection
  13789.         dc.l    mbc1_ram_protection        ;$2000.
  13790.  
  13791.         dc.l    mbc1_rom_switch
  13792.         dc.l    mbc1_rom_switch
  13793.         dc.l    mbc1_rom_switch
  13794.         dc.l    mbc1_rom_switch            ;$4000.
  13795.  
  13796.         dc.l    mbc1_rom_switch_two_address_lines
  13797.         dc.l    mbc1_rom_switch_two_address_lines
  13798.         dc.l    mbc1_rom_switch_two_address_lines
  13799.         dc.l    mbc1_rom_switch_two_address_lines
  13800.                             ;$6000.
  13801.         dc.l    mbc1_rom_mode_select
  13802.         dc.l    mbc1_rom_mode_select
  13803.         dc.l    mbc1_rom_mode_select
  13804.         dc.l    mbc1_rom_mode_select        ;$8000.
  13805.  
  13806.         dc.l    gb_mem_wr
  13807.         dc.l    gb_mem_wr
  13808.         dc.l    gb_mem_wr
  13809.         dc.l    gb_mem_wr            ;$a000.
  13810.  
  13811.         dc.l    gb_mem_wr
  13812.         dc.l    gb_mem_wr
  13813.         dc.l    gb_mem_wr
  13814.         dc.l    gb_mem_wr            ;$c000.
  13815.  
  13816. ;        dc.l    gb_mem_wr
  13817. ;        dc.l    gb_mem_wr_denied
  13818. ;        dc.l    gb_mem_wr_denied
  13819. ;        dc.l    gb_mem_wr_denied        ;$c000.
  13820.  
  13821. mapper_huc1_8kb_ram:
  13822.         dc.l    4-1,$2000-1
  13823.         dc.l    mbc1_ram_protection
  13824.         dc.l    mbc1_rom_switch
  13825.         dc.l    mbc1_rom_switch_two_address_lines
  13826.         dc.l    mbc1_rom_mode_select
  13827.  
  13828. mapper_huc1_32kb_ram:
  13829.         dc.l    4-1,$2000-1
  13830.         dc.l    mbc1_ram_protection
  13831.         dc.l    mbc1_rom_switch
  13832.         dc.l    mbc1_ram_switch_with_two_rom_address_lines
  13833.         dc.l    mbc1_rom_mode_select
  13834.  
  13835. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13836. ;        ROM+MBC5+RAM (+BATTERY)
  13837. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13838.  
  13839. mapper_mbc5_ram:
  13840. mapper_mbc5_ram_battery:
  13841. mapper_mbc5_rumble_sram:
  13842. mapper_mbc5_rumble_sram_battery:
  13843.         dc.l    mapper_mbc5_0kb_ram
  13844.         dc.l    mapper_mbc5_2kb_ram
  13845.         dc.l    mapper_mbc5_8kb_ram
  13846.         dc.l    mapper_mbc5_32kb_ram
  13847.         dc.l    mapper_mbc5_128kb_ram
  13848.  
  13849. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13850. ;        ROM+MBC5
  13851. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13852.  
  13853. mapper_mbc5:
  13854. mapper_mbc5_rumble:
  13855.         dc.l    mapper_mbc5_0kb_ram
  13856.         dc.l    mapper_mbc5_0kb_ram
  13857.         dc.l    mapper_mbc5_0kb_ram
  13858.         dc.l    mapper_mbc5_0kb_ram
  13859.         dc.l    mapper_mbc5_0kb_ram
  13860.  
  13861. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13862. ;        MBC5
  13863. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13864.  
  13865. mapper_mbc5_0kb_ram:
  13866.         dc.l    8-1,$1000-1
  13867.         dc.l    rom_write
  13868.         dc.l    rom_write
  13869.         dc.l    mbc5_romb0            ;$3000.
  13870.         dc.l    mbc5_romb1            ;$4000.
  13871.         dc.l    rom_write
  13872.         dc.l    rom_write
  13873.         dc.l    rom_write
  13874.         dc.l    rom_write            ;$8000.
  13875.  
  13876. mapper_mbc5_2kb_ram:
  13877.         dc.l    8-1,$1000-1
  13878.         dc.l    rom_write
  13879.         dc.l    rom_write
  13880.         dc.l    mbc5_romb0            ;$3000.
  13881.         dc.l    mbc5_romb1            ;$4000.
  13882.         dc.l    rom_write
  13883.         dc.l    rom_write
  13884.         dc.l    rom_write
  13885.         dc.l    rom_write            ;$8000.
  13886.  
  13887. mapper_mbc5_8kb_ram:
  13888.         dc.l    8-1,$1000-1
  13889.         dc.l    rom_write
  13890.         dc.l    rom_write
  13891.         dc.l    mbc5_romb0            ;$3000.
  13892.         dc.l    mbc5_romb1            ;$4000.
  13893.         dc.l    rom_write
  13894.         dc.l    rom_write
  13895.         dc.l    rom_write
  13896.         dc.l    rom_write            ;$8000.
  13897.  
  13898. mapper_mbc5_32kb_ram:
  13899.         dc.l    8-1,$1000-1
  13900.         dc.l    mbc5_ramg
  13901.         dc.l    mbc5_ramg            ;$2000.
  13902.         dc.l    mbc5_romb0            ;$3000.
  13903.         dc.l    mbc5_romb1            ;$4000.
  13904.         dc.l    mbc5_ramb
  13905.         dc.l    mbc5_ramb            ;$6000.
  13906.         dc.l    rom_write
  13907.         dc.l    rom_write            ;$8000.
  13908.  
  13909. mapper_mbc5_128kb_ram:
  13910.         dc.l    8-1,$1000-1
  13911.         dc.l    mbc5_ramg
  13912.         dc.l    mbc5_ramg            ;$2000.
  13913.         dc.l    mbc5_romb0            ;$3000.
  13914.         dc.l    mbc5_romb1            ;$4000.
  13915.         dc.l    mbc5_ramb
  13916.         dc.l    mbc5_ramb            ;$6000.
  13917.         dc.l    rom_write
  13918.         dc.l    rom_write            ;$8000.
  13919.  
  13920. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13921. ;        ROM+MBC3+RAM (+BATTERY)
  13922. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13923.  
  13924. mapper_mbc3_timer_ram_battery:
  13925. mapper_mbc3_timer_battery:
  13926. mapper_mbc3:
  13927. mapper_mbc3_ram:
  13928. mapper_mbc3_ram_battery:
  13929.         dc.l    mapper_mbc3_0kb_ram
  13930.         dc.l    mapper_mbc3_2kb_ram
  13931.         dc.l    mapper_mbc3_8kb_ram
  13932.         dc.l    mapper_mbc3_32kb_ram
  13933.  
  13934. mapper_mbc3_0kb_ram:
  13935.         dc.l    4-1,$2000-1
  13936.         dc.l    mbc3_ram_protection
  13937.         dc.l    mbc3_rom_switch
  13938.         dc.l    rom_write
  13939.         dc.l    mbc3_latch_clock_counter_data
  13940.  
  13941. mapper_mbc3_2kb_ram:
  13942.         dc.l    4-1,$2000-1
  13943.         dc.l    mbc3_ram_protection
  13944.         dc.l    mbc3_rom_switch
  13945.         dc.l    rom_write
  13946.         dc.l    mbc3_latch_clock_counter_data
  13947.  
  13948. mapper_mbc3_8kb_ram:
  13949.         dc.l    4-1,$2000-1
  13950.         dc.l    mbc3_ram_protection
  13951.         dc.l    mbc3_rom_switch
  13952.         dc.l    rom_write
  13953.         dc.l    mbc3_latch_clock_counter_data
  13954.  
  13955. mapper_mbc3_32kb_ram:
  13956.         dc.l    4-1,$2000-1
  13957.         dc.l    mbc3_ram_protection
  13958.         dc.l    mbc3_rom_switch
  13959.         dc.l    mbc3_ram_switch_change_ram_bank
  13960.         dc.l    mbc3_latch_clock_counter_data
  13961.  
  13962. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13963. ;        ROM ONLY
  13964. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13965.  
  13966. mapper_na:    dc.l    mapper_pure_rom
  13967.         dc.l    mapper_pure_rom
  13968.         dc.l    mapper_pure_rom
  13969.         dc.l    mapper_pure_rom
  13970.  
  13971. mapper_pure_rom:dc.l    6-1,$2000-1
  13972.         dc.l    rom_write
  13973.         dc.l    rom_write
  13974.         dc.l    rom_write
  13975.         dc.l    rom_write
  13976.         dc.l    gb_mem_wr
  13977.         dc.l    gb_mem_wr
  13978.  
  13979. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13980. ;        ROM+MBC1
  13981. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13982.  
  13983. mapper_mbc1:    dc.l    mapper_mbc1_no_ram
  13984.         dc.l    mapper_mbc1_no_ram
  13985.         dc.l    mapper_mbc1_no_ram
  13986.         dc.l    mapper_mbc1_no_ram
  13987.  
  13988. mapper_mbc1_no_ram:
  13989.         dc.l    6-1,$2000-1
  13990.         dc.l    rom_write
  13991.         dc.l    mbc1_rom_switch
  13992.         dc.l    mbc1_rom_switch_two_address_lines
  13993.         dc.l    mbc1_rom_mode_select
  13994.         dc.l    gb_mem_wr
  13995.         dc.l    gb_mem_wr
  13996.  
  13997. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  13998. ;        ROM+MBC1+RAM (+BATTERY)
  13999. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14000.  
  14001. mapper_mbc1_ram:
  14002. mapper_mbc1_ram_battery:
  14003.         dc.l    mapper_mbc1_0kb_ram
  14004.         dc.l    mapper_mbc1_2kb_ram
  14005.         dc.l    mapper_mbc1_8kb_ram
  14006.         dc.l    mapper_mbc1_32kb_ram
  14007.  
  14008. mapper_mbc1_0kb_ram:
  14009.         dc.l    6-1,$2000-1
  14010.         dc.l    rom_write
  14011.         dc.l    mbc1_rom_switch
  14012.         dc.l    mbc1_rom_switch_two_address_lines
  14013.         dc.l    mbc1_rom_mode_select
  14014.         dc.l    gb_mem_wr
  14015.         dc.l    gb_mem_wr
  14016.  
  14017. mapper_mbc1_2kb_ram:
  14018.         dc.l    24-1,$800-1
  14019.  
  14020.         dc.l    mbc1_ram_protection
  14021.         dc.l    mbc1_ram_protection
  14022.         dc.l    mbc1_ram_protection
  14023.         dc.l    mbc1_ram_protection        ;$2000.
  14024.  
  14025.         dc.l    mbc1_rom_switch
  14026.         dc.l    mbc1_rom_switch
  14027.         dc.l    mbc1_rom_switch
  14028.         dc.l    mbc1_rom_switch            ;$4000.
  14029.  
  14030.         dc.l    mbc1_rom_switch_two_address_lines
  14031.         dc.l    mbc1_rom_switch_two_address_lines
  14032.         dc.l    mbc1_rom_switch_two_address_lines
  14033.         dc.l    mbc1_rom_switch_two_address_lines
  14034.                             ;$6000.
  14035.         dc.l    mbc1_rom_mode_select
  14036.         dc.l    mbc1_rom_mode_select
  14037.         dc.l    mbc1_rom_mode_select
  14038.         dc.l    mbc1_rom_mode_select        ;$8000.
  14039.  
  14040.         dc.l    gb_mem_wr
  14041.         dc.l    gb_mem_wr
  14042.         dc.l    gb_mem_wr
  14043.         dc.l    gb_mem_wr            ;$a000.
  14044.  
  14045.         dc.l    gb_mem_wr
  14046.         dc.l    gb_mem_wr
  14047.         dc.l    gb_mem_wr
  14048.         dc.l    gb_mem_wr            ;$c000.
  14049.  
  14050. mapper_mbc1_8kb_ram:
  14051.         dc.l    4-1,$2000-1
  14052.         dc.l    mbc1_ram_protection
  14053.         dc.l    mbc1_rom_switch
  14054.         dc.l    mbc1_rom_switch_two_address_lines
  14055.         dc.l    mbc1_rom_mode_select
  14056.  
  14057. mapper_mbc1_32kb_ram:
  14058.         dc.l    4-1,$2000-1
  14059.         dc.l    mbc1_ram_protection
  14060.         dc.l    mbc1_rom_switch
  14061.         dc.l    mbc1_ram_switch_with_two_rom_address_lines
  14062.         dc.l    mbc1_rom_mode_select
  14063.  
  14064. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14065. ;        ROM+MBC2 (+BATTERY)
  14066. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14067.  
  14068. mapper_mbc2:
  14069. mapper_mbc2_battery:
  14070.         dc.l    mapper_mbc2_256b_ram
  14071.         dc.l    mapper_mbc2_256b_ram
  14072.         dc.l    mapper_mbc2_256b_ram
  14073.         dc.l    mapper_mbc2_256b_ram
  14074.  
  14075. mapper_mbc2_256b_ram:
  14076.         dc.l    192-1,$100-1
  14077.         dc.l    mbc2_ram_protection
  14078.         dc.l    rom_write
  14079.         dc.l    mbc2_ram_protection
  14080.         dc.l    rom_write
  14081.         dc.l    mbc2_ram_protection
  14082.         dc.l    rom_write
  14083.         dc.l    mbc2_ram_protection
  14084.         dc.l    rom_write
  14085.         dc.l    mbc2_ram_protection
  14086.         dc.l    rom_write
  14087.         dc.l    mbc2_ram_protection
  14088.         dc.l    rom_write
  14089.         dc.l    mbc2_ram_protection
  14090.         dc.l    rom_write
  14091.         dc.l    mbc2_ram_protection
  14092.         dc.l    rom_write
  14093.         dc.l    mbc2_ram_protection
  14094.         dc.l    rom_write
  14095.         dc.l    mbc2_ram_protection
  14096.         dc.l    rom_write
  14097.         dc.l    mbc2_ram_protection
  14098.         dc.l    rom_write
  14099.         dc.l    mbc2_ram_protection
  14100.         dc.l    rom_write
  14101.         dc.l    mbc2_ram_protection
  14102.         dc.l    rom_write
  14103.         dc.l    mbc2_ram_protection
  14104.         dc.l    rom_write
  14105.         dc.l    mbc2_ram_protection
  14106.         dc.l    rom_write
  14107.         dc.l    mbc2_ram_protection
  14108.         dc.l    rom_write            ;$2000.
  14109.  
  14110.         dc.l    rom_write
  14111.         dc.l    mbc2_rom_switch
  14112.         dc.l    rom_write
  14113.         dc.l    mbc2_rom_switch
  14114.         dc.l    rom_write
  14115.         dc.l    mbc2_rom_switch
  14116.         dc.l    rom_write
  14117.         dc.l    mbc2_rom_switch
  14118.         dc.l    rom_write
  14119.         dc.l    mbc2_rom_switch
  14120.         dc.l    rom_write
  14121.         dc.l    mbc2_rom_switch
  14122.         dc.l    rom_write
  14123.         dc.l    mbc2_rom_switch
  14124.         dc.l    rom_write
  14125.         dc.l    mbc2_rom_switch
  14126.         dc.l    rom_write
  14127.         dc.l    mbc2_rom_switch
  14128.         dc.l    rom_write
  14129.         dc.l    mbc2_rom_switch
  14130.         dc.l    rom_write
  14131.         dc.l    mbc2_rom_switch
  14132.         dc.l    rom_write
  14133.         dc.l    mbc2_rom_switch
  14134.         dc.l    rom_write
  14135.         dc.l    mbc2_rom_switch
  14136.         dc.l    rom_write
  14137.         dc.l    mbc2_rom_switch
  14138.         dc.l    rom_write
  14139.         dc.l    mbc2_rom_switch
  14140.         dc.l    rom_write
  14141.         dc.l    mbc2_rom_switch            ;$4000.
  14142.  
  14143.         dc.l    rom_write
  14144.         dc.l    rom_write
  14145.         dc.l    rom_write
  14146.         dc.l    rom_write
  14147.         dc.l    rom_write
  14148.         dc.l    rom_write
  14149.         dc.l    rom_write
  14150.         dc.l    rom_write
  14151.         dc.l    rom_write
  14152.         dc.l    rom_write
  14153.         dc.l    rom_write
  14154.         dc.l    rom_write
  14155.         dc.l    rom_write
  14156.         dc.l    rom_write
  14157.         dc.l    rom_write
  14158.         dc.l    rom_write
  14159.         dc.l    rom_write
  14160.         dc.l    rom_write
  14161.         dc.l    rom_write
  14162.         dc.l    rom_write
  14163.         dc.l    rom_write
  14164.         dc.l    rom_write
  14165.         dc.l    rom_write
  14166.         dc.l    rom_write
  14167.         dc.l    rom_write
  14168.         dc.l    rom_write
  14169.         dc.l    rom_write
  14170.         dc.l    rom_write
  14171.         dc.l    rom_write
  14172.         dc.l    rom_write
  14173.         dc.l    rom_write
  14174.         dc.l    rom_write            ;$6000.
  14175.  
  14176.         dc.l    rom_write
  14177.         dc.l    rom_write
  14178.         dc.l    rom_write
  14179.         dc.l    rom_write
  14180.         dc.l    rom_write
  14181.         dc.l    rom_write
  14182.         dc.l    rom_write
  14183.         dc.l    rom_write
  14184.         dc.l    rom_write
  14185.         dc.l    rom_write
  14186.         dc.l    rom_write
  14187.         dc.l    rom_write
  14188.         dc.l    rom_write
  14189.         dc.l    rom_write
  14190.         dc.l    rom_write
  14191.         dc.l    rom_write
  14192.         dc.l    rom_write
  14193.         dc.l    rom_write
  14194.         dc.l    rom_write
  14195.         dc.l    rom_write
  14196.         dc.l    rom_write
  14197.         dc.l    rom_write
  14198.         dc.l    rom_write
  14199.         dc.l    rom_write
  14200.         dc.l    rom_write
  14201.         dc.l    rom_write
  14202.         dc.l    rom_write
  14203.         dc.l    rom_write
  14204.         dc.l    rom_write
  14205.         dc.l    rom_write
  14206.         dc.l    rom_write
  14207.         dc.l    rom_write            ;$8000.
  14208.  
  14209.         dc.l    gb_mem_wr
  14210.         dc.l    gb_mem_wr
  14211.         dc.l    gb_mem_wr
  14212.         dc.l    gb_mem_wr
  14213.         dc.l    gb_mem_wr
  14214.         dc.l    gb_mem_wr
  14215.         dc.l    gb_mem_wr
  14216.         dc.l    gb_mem_wr
  14217.         dc.l    gb_mem_wr
  14218.         dc.l    gb_mem_wr
  14219.         dc.l    gb_mem_wr
  14220.         dc.l    gb_mem_wr
  14221.         dc.l    gb_mem_wr
  14222.         dc.l    gb_mem_wr
  14223.         dc.l    gb_mem_wr
  14224.         dc.l    gb_mem_wr
  14225.         dc.l    gb_mem_wr
  14226.         dc.l    gb_mem_wr
  14227.         dc.l    gb_mem_wr
  14228.         dc.l    gb_mem_wr
  14229.         dc.l    gb_mem_wr
  14230.         dc.l    gb_mem_wr
  14231.         dc.l    gb_mem_wr
  14232.         dc.l    gb_mem_wr
  14233.         dc.l    gb_mem_wr
  14234.         dc.l    gb_mem_wr
  14235.         dc.l    gb_mem_wr
  14236.         dc.l    gb_mem_wr
  14237.         dc.l    gb_mem_wr
  14238.         dc.l    gb_mem_wr
  14239.         dc.l    gb_mem_wr
  14240.         dc.l    gb_mem_wr            ;a000.
  14241.  
  14242.         dc.l    gb_mem_wr
  14243.         dc.l    gb_mem_wr
  14244.         dc.l    gb_mem_wr
  14245.         dc.l    gb_mem_wr
  14246.         dc.l    gb_mem_wr
  14247.         dc.l    gb_mem_wr
  14248.         dc.l    gb_mem_wr
  14249.         dc.l    gb_mem_wr
  14250.         dc.l    gb_mem_wr
  14251.         dc.l    gb_mem_wr
  14252.         dc.l    gb_mem_wr
  14253.         dc.l    gb_mem_wr
  14254.         dc.l    gb_mem_wr
  14255.         dc.l    gb_mem_wr
  14256.         dc.l    gb_mem_wr
  14257.         dc.l    gb_mem_wr
  14258.         dc.l    gb_mem_wr
  14259.         dc.l    gb_mem_wr
  14260.         dc.l    gb_mem_wr
  14261.         dc.l    gb_mem_wr
  14262.         dc.l    gb_mem_wr
  14263.         dc.l    gb_mem_wr
  14264.         dc.l    gb_mem_wr
  14265.         dc.l    gb_mem_wr
  14266.         dc.l    gb_mem_wr
  14267.         dc.l    gb_mem_wr
  14268.         dc.l    gb_mem_wr
  14269.         dc.l    gb_mem_wr
  14270.         dc.l    gb_mem_wr
  14271.         dc.l    gb_mem_wr
  14272.         dc.l    gb_mem_wr
  14273.         dc.l    gb_mem_wr            ;$c000.
  14274.  
  14275. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14276. ;        ROM+RAM (+BATTERY)
  14277. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14278.  
  14279. mapper_ram:
  14280. mapper_ram_battery:
  14281.         dc.l    mapper_ram_0kb_ram
  14282.         dc.l    mapper_ram_2kb_ram
  14283.         dc.l    mapper_ram_8kb_ram
  14284.         dc.l    mapper_ram_8kb_ram        ;illegal?
  14285.  
  14286. mapper_ram_0kb_ram:
  14287.         dc.l    6-1,$2000-1
  14288.         dc.l    rom_write
  14289.         dc.l    rom_write
  14290.         dc.l    rom_write
  14291.         dc.l    rom_write
  14292.         dc.l    gb_mem_wr
  14293.         dc.l    gb_mem_wr
  14294.  
  14295. mapper_ram_2kb_ram:
  14296.         dc.l    24-1,$800-1
  14297.  
  14298.         dc.l    rom_write
  14299.         dc.l    rom_write
  14300.         dc.l    rom_write
  14301.         dc.l    rom_write            ;$2000.
  14302.  
  14303.         dc.l    rom_write
  14304.         dc.l    rom_write
  14305.         dc.l    rom_write
  14306.         dc.l    rom_write            ;$4000.
  14307.  
  14308.         dc.l    rom_write
  14309.         dc.l    rom_write
  14310.         dc.l    rom_write
  14311.         dc.l    rom_write            ;$6000.
  14312.  
  14313.         dc.l    rom_write
  14314.         dc.l    rom_write
  14315.         dc.l    rom_write
  14316.         dc.l    rom_write            ;$8000.
  14317.  
  14318.         dc.l    gb_mem_wr
  14319.         dc.l    gb_mem_wr
  14320.         dc.l    gb_mem_wr
  14321.         dc.l    gb_mem_wr            ;$a000.
  14322.  
  14323.         dc.l    gb_mem_wr
  14324.         dc.l    gb_mem_wr
  14325.         dc.l    gb_mem_wr
  14326.         dc.l    gb_mem_wr            ;$c000.
  14327.  
  14328. mapper_ram_8kb_ram:
  14329.         dc.l    4-1,$2000-1
  14330.         dc.l    rom_write
  14331.         dc.l    rom_write
  14332.         dc.l    rom_write
  14333.         dc.l    rom_write
  14334.  
  14335. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14336. ;        output screen for gameboy
  14337. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14338.  
  14339. gb_taglist:    dc.l    SA_Width,160
  14340.         dc.l    SA_Height,144
  14341. gb_taglist_x:    dc.l    SA_Left,0
  14342. gb_taglist_y:    dc.l    SA_Top,0
  14343.         dc.l    SA_Depth,4
  14344.         dc.l    SA_BlockPen,2
  14345.         dc.l    SA_DetailPen,1
  14346.         dc.l    SA_Pens,pens_empty
  14347.         dc.l    SA_Type,CUSTOMSCREEN
  14348.         dc.l    SA_AutoScroll,TRUE
  14349.         dc.l    SA_ShowTitle,FALSE
  14350.         dc.l    SA_Behind,TRUE
  14351.         dc.l    SA_Quiet,TRUE            ;no title, no gadgets.
  14352.         dc.l    SA_Font,font_attr
  14353. gb_screen_id:    dc.l    SA_DisplayID,PAL_MONITOR_ID!LORES_KEY
  14354.                             ;default = pal.
  14355.         dc.l    SA_Draggable,TRUE
  14356.         dc.l    SA_VideoControl,video_tags    ;v39 only.
  14357.         dc.l    SA_Interleaved,FALSE
  14358.         dc.l    SA_Overscan,OSCAN_STANDARD
  14359.         dc.l    TAG_END,0
  14360.  
  14361. video_tags:    dc.l    VTAG_BORDERBLANK_SET,TRUE
  14362.         dc.l    TAG_END,0
  14363.  
  14364. pens_empty:    dc.w    0,-1                ;3d look, thanks!
  14365.  
  14366. gb_bplanes_I:    dc.l    0
  14367. gb_bplanes_II:    dc.l    0
  14368.  
  14369. gb_bmap_I:    dc.l    0
  14370. gb_bmap_II:    dc.l    0
  14371.  
  14372. gb_rport_I:    dc.l    0
  14373. gb_rport_II:    dc.l    0
  14374.  
  14375. gb_screen_ptr:    dc.l    0
  14376.  
  14377. gb_buffer_no:    dc.b    0
  14378.         even
  14379.  
  14380. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14381. ;        game window
  14382. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14383.  
  14384. wzonka_ptr:    dc.l    0
  14385. wzonka_window_x:dc.w    160
  14386. wzonka_window_y:dc.w    144
  14387. wzonka_game_x:    dc.l    0
  14388. wzonka_game_y:    dc.l    0
  14389.  
  14390. game_array:    dc.l    0
  14391. game_scale_array:
  14392.         dc.l    0
  14393. game_rast_port:    dc.l    0
  14394. game_tmp_rast_port:
  14395.         dc.l    0
  14396. game_tmp_map_attr:
  14397.         dc.l    0
  14398. game_output_tmp_rast_port:
  14399.         dc.l    0
  14400. game_output_tmp_map_attr:
  14401.         dc.l    0
  14402.  
  14403. wzonka_window:    dc.w    0
  14404.         dc.w    0
  14405.         dc.w    160
  14406.         dc.w    144
  14407.         dc.b    0
  14408.         dc.b    1
  14409.         dc.l    0
  14410.         dc.l    0
  14411.         dc.l    0
  14412.         dc.l    0
  14413.         dc.l    wzonka_title
  14414.         dc.l    0
  14415.         dc.l    0
  14416.         dc.w    160
  14417.         dc.w    144
  14418.         dc.w    480+24
  14419.         dc.w    432+24
  14420.         dc.w    WBENCHSCREEN
  14421.  
  14422. wzonka_title:    dc.b    " ",0
  14423.         even
  14424.  
  14425. wzonka_window_title_txt:
  14426.         dc.b    "Gameboy "
  14427. wzonka_window_title_x:
  14428.         dc.b    "   "
  14429.         dc.b    "x"
  14430. wzonka_window_title_y:
  14431.         dc.b    "   ",0
  14432.         even
  14433.  
  14434. wzonka_window_screen_txt:
  14435.         dc.b    "Wzonka-Lad Game Window",0
  14436.         even
  14437.  
  14438. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14439. ;        the frequency adder
  14440. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14441.  
  14442. freq_storage:    dc.l    0
  14443.  
  14444. freq_table:    dc.l    363                ;(4096*4096)/(60*154*5).
  14445.         dc.l    23241                ;(262144*4096)/(60*154*5).
  14446.         dc.l    5810                ;(65536*4096)/(60*154*5).
  14447.         dc.l    1452                ;(16384*4096)/(60*154*5).
  14448.  
  14449. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14450. ;        the copperlist base model
  14451. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14452.  
  14453. aga_copper:    dc.w    fmode,%1111            ;64 bits wide bandwidth.
  14454.         dc.w    ddfstrt,$38            ;$0
  14455.         dc.w    ddfstop,$38+(160+64-16)/2    ;$40+(160-16)/2
  14456.         dc.w    diwstrt,$2cc1            ;$2c81
  14457.         dc.w    diwstop,$bc61            ;$100*($2c+144)+$21
  14458.         dc.w    bplcon0,%0000010000010000    ;eight planes + dpf.
  14459.         dc.w    bpl1mod,40*7-8+16-8        ;64 bit fix.
  14460.         dc.w    bpl2mod,40*7-8+16-8        ;64 bit fix.
  14461.         dc.w    $1011,$fffe            ;timing fix (vbr copier).
  14462. aga_scr_0:    dc.w    bplcon1,0            ;plane shifting.
  14463.         dc.w    bplcon2,%1000100        ;spr & dpf priorities.
  14464.         dc.w    bplcon3,$0000+Q
  14465.         dc.w    bplcon4,%00100011        ;spr palettes.
  14466. aga_col:    dc.w    c0,$000,bplcon3,$200+Q,c0,$000,bplcon3,$0000+Q    ;c0.
  14467.         dc.w    c1,$000,bplcon3,$200+Q,c1,$000,bplcon3,$0000+Q
  14468.         dc.w    c2,$000,bplcon3,$200+Q,c2,$000,bplcon3,$0000+Q
  14469.         dc.w    c3,$000,bplcon3,$200+Q,c3,$000,bplcon3,$0000+Q
  14470.         dc.w    c4,$000,bplcon3,$200+Q,c4,$000,bplcon3,$0000+Q    ;c0.
  14471.         dc.w    c17,$000,bplcon3,$200+Q,c17,$000,bplcon3,$0000+Q
  14472.         dc.w    c18,$000,bplcon3,$200+Q,c18,$000,bplcon3,$0000+Q
  14473.         dc.w    c19,$000,bplcon3,$200+Q,c19,$000,bplcon3,$0000+Q
  14474.         dc.w    c4,$000,bplcon3,$200+Q,c4,$000,bplcon3,$0000+Q    ;c0.
  14475.         dc.w    c20,$000,bplcon3,$200+Q,c20,$000,bplcon3,$0000+Q
  14476.         dc.w    c24,$000,bplcon3,$200+Q,c24,$000,bplcon3,$0000+Q
  14477.         dc.w    c28,$000,bplcon3,$200+Q,c28,$000,bplcon3,$2000+Q
  14478. spr_col:    dc.w    c19,$000,bplcon3,$2200+Q,c19,$000,bplcon3,$2000+Q
  14479.         dc.w    c1,$000,bplcon3,$2200+Q,c1,$000,bplcon3,$2000+Q
  14480.         dc.w    c2,$000,bplcon3,$2200+Q,c2,$000,bplcon3,$2000+Q
  14481.         dc.w    c3,$000,bplcon3,$2200+Q,c3,$000,bplcon3,$2000+Q
  14482.         dc.w    c23,$000,bplcon3,$2200+Q,c23,$000,bplcon3,$2000+Q
  14483.         dc.w    c5,$000,bplcon3,$2200+Q,c5,$000,bplcon3,$2000+Q
  14484.         dc.w    c6,$000,bplcon3,$2200+Q,c6,$000,bplcon3,$2000+Q
  14485.         dc.w    c7,$000,bplcon3,$2200+Q,c7,$000,bplcon3,$2000+Q
  14486.         dc.w    c27,$000,bplcon3,$2200+Q,c27,$000,bplcon3,$2000+Q
  14487.         dc.w    c9,$000,bplcon3,$2200+Q,c9,$000,bplcon3,$2000+Q
  14488.         dc.w    c10,$000,bplcon3,$2200+Q,c10,$000,bplcon3,$2000+Q
  14489.         dc.w    c11,$000,bplcon3,$2200+Q,c11,$000,bplcon3,$2000+Q
  14490.         dc.w    c31,$000,bplcon3,$2200+Q,c31,$000,bplcon3,$2000+Q
  14491.         dc.w    c13,$000,bplcon3,$2200+Q,c13,$000,bplcon3,$2000+Q
  14492.         dc.w    c14,$000,bplcon3,$2200+Q,c14,$000,bplcon3,$2000+Q
  14493.         dc.w    c15,$000,bplcon3,$2200+Q,c15,$000,bplcon3,$0000+Q
  14494. aga_sprites:    dc.w    spr0pth,0,spr0ptl,0
  14495.         dc.w    spr2pth,0,spr2ptl,0
  14496.         dc.w    spr4pth,0,spr4ptl,0
  14497.         dc.w    spr6pth,0,spr6ptl,0
  14498.         dc.w    spr1pth,0,spr1ptl,0
  14499.         dc.w    spr3pth,0,spr3ptl,0
  14500.         dc.w    spr5pth,0,spr5ptl,0
  14501.         dc.w    spr7pth,0,spr7ptl,0
  14502.         dc.w    $2a11,$fffe
  14503. aga_planes:    dc.w    bpl1pth,0,bpl1ptl,0
  14504.         dc.w    bpl3pth,0,bpl3ptl,0
  14505.         dc.w    bpl5pth,0,bpl5ptl,0
  14506.         dc.w    bpl7pth,0,bpl7ptl,0
  14507.         dc.w    bpl2pth,0,bpl2ptl,0
  14508.         dc.w    bpl4pth,0,bpl4ptl,0
  14509.         dc.w    bpl6pth,0,bpl6ptl,0
  14510.         dc.w    bpl8pth,0,bpl8ptl,0
  14511. aga_scr_x:    
  14512.  
  14513. c0              EQU color
  14514. c1              EQU color+2
  14515. c2              EQU color+4
  14516. c3              EQU color+6
  14517. c4              EQU color+8
  14518. c5              EQU color+10
  14519. c6              EQU color+12
  14520. c7              EQU color+14
  14521. c9              EQU color+18
  14522. c10             EQU color+20
  14523. c11             EQU color+22
  14524. c13             EQU color+26
  14525. c14             EQU color+28
  14526. c15             EQU color+30
  14527. c17             EQU color+34
  14528. c18             EQU color+36
  14529. c19             EQU color+38
  14530. c20             EQU color+40
  14531. c23             EQU color+46
  14532. c24             EQU color+48
  14533. c26             EQU color+52
  14534. c27             EQU color+54
  14535. c28             EQU color+56
  14536. c31             EQU color+62
  14537.  
  14538. bpl1pth         EQU bplpt
  14539. bpl1ptl         EQU bplpt+2
  14540. bpl2pth         EQU bplpt+4
  14541. bpl2ptl         EQU bplpt+6
  14542. bpl3pth         EQU bplpt+8
  14543. bpl3ptl         EQU bplpt+10
  14544. bpl4pth         EQU bplpt+12
  14545. bpl4ptl         EQU bplpt+14
  14546. bpl5pth         EQU bplpt+16
  14547. bpl5ptl         EQU bplpt+18
  14548. bpl6pth         EQU bplpt+20
  14549. bpl6ptl         EQU bplpt+22
  14550. bpl7pth         EQU bplpt+24
  14551. bpl7ptl         EQU bplpt+26
  14552. bpl8pth         EQU bplpt+28
  14553. bpl8ptl         EQU bplpt+30
  14554.  
  14555. spr0pth         EQU sprpt
  14556. spr0ptl         EQU sprpt+2
  14557. spr1pth         EQU sprpt+4
  14558. spr1ptl         EQU sprpt+6
  14559. spr2pth         EQU sprpt+8
  14560. spr2ptl         EQU sprpt+10
  14561. spr3pth         EQU sprpt+12
  14562. spr3ptl         EQU sprpt+14
  14563. spr4pth         EQU sprpt+16
  14564. spr4ptl         EQU sprpt+18
  14565. spr5pth         EQU sprpt+20
  14566. spr5ptl         EQU sprpt+22
  14567. spr6pth         EQU sprpt+24
  14568. spr6ptl         EQU sprpt+26
  14569. spr7pth         EQU sprpt+28
  14570. spr7ptl         EQU sprpt+30
  14571.  
  14572. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14573. ;        value get tag lists for gadgets
  14574. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14575.  
  14576. get_mx_attr:    dc.l    GTMX_Active,mx_attr_value
  14577.         dc.l    TAG_END,0
  14578. mx_attr_value:    dc.l    0
  14579.  
  14580. get_checkbox_attr:
  14581.         dc.l    GTCB_Checked,checkbox_status
  14582.         dc.l    TAG_END,0
  14583. checkbox_status:dc.l    0
  14584.  
  14585. get_slider_attr:dc.l    GTSL_Level,slider_attr_value
  14586.         dc.l    TAG_END,0
  14587. slider_attr_value:
  14588.         dc.l    0
  14589.  
  14590. get_listview_attr:dc.l    GTLV_Selected,listview_attr_value
  14591.         dc.l    TAG_END,0
  14592. listview_attr_value:
  14593.         dc.l    0
  14594.  
  14595. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14596. ;        sound variables
  14597. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14598.  
  14599. freq_s_I:    dc.l    0
  14600. freq_s_I_ctrl:    dc.w    0
  14601.         dc.b    0
  14602. freq_s_I_ctrl_x:dc.b    0
  14603.  
  14604. sound_V:    dc.b    0
  14605. sound_V_b:    dc.b    0
  14606.         dc.w    0
  14607.  
  14608. pan_table:    dc.l    0
  14609.         dc.l    0
  14610.         dc.l    $10000
  14611.         dc.l    $10000/2
  14612.  
  14613. onf_table:    dc.b    1                    ;off.
  14614.         dc.b    0                    ;on (left).
  14615.         dc.b    0                    ;   (right).
  14616.         dc.b    0                    ;   (both).
  14617.  
  14618. sound_so_list:    dc.l    0                    ;off.
  14619. sound_so_1:    dc.w    0                    ;so 1.
  14620.         dc.b    0
  14621. sound_so_1x:    dc.b    0
  14622. sound_so_2:    dc.w    0                    ;so 2.
  14623.         dc.b    0
  14624. sound_so_2x:    dc.b    0
  14625. sound_so_mix:    dc.w    0                    ;(so 1+so 2)/2.
  14626.         dc.b    0
  14627. sound_so_mixx:    dc.b    0
  14628.  
  14629. sound_I_v_envelope:
  14630.         dc.b    0
  14631. sound_I_f_envelope:
  14632.         dc.b    0
  14633. sound_II_v_envelope:
  14634.         dc.b    0
  14635. sound_IV_v_envelope:
  14636.         dc.b    0
  14637. sound_I_v_envelope_initial_volume:
  14638.         dc.b    0
  14639. sound_II_v_envelope_initial_volume:
  14640.         dc.b    0
  14641. sound_IV_v_envelope_initial_volume:
  14642.         dc.b    0
  14643.  
  14644.         even
  14645.  
  14646. sound_I_f_envelope_counter_base:
  14647.         dc.l    0
  14648. sound_I_f_envelope_counter:
  14649.         dc.l    0
  14650. sound_I_f_initial_frequency:
  14651.         dc.l    0
  14652.  
  14653. sound_I_v_envelope_counter_base:
  14654.         dc.l    0
  14655. sound_I_v_envelope_counter:
  14656.         dc.l    0
  14657. sound_II_v_envelope_counter_base:
  14658.         dc.l    0
  14659. sound_II_v_envelope_counter:
  14660.         dc.l    0
  14661. sound_IV_v_envelope_counter_base:
  14662.         dc.l    0
  14663. sound_IV_v_envelope_counter:
  14664.         dc.l    0
  14665.  
  14666. sound_I_status:    
  14667. sound_I_onf:    dc.b    0
  14668. sound_I_onf_vin:dc.b    0
  14669. sound_I_onf_master:
  14670.         dc.b    0
  14671. sound_I_onf_kick:
  14672.         dc.b    0
  14673.  
  14674. sound_II_status:
  14675. sound_II_onf:    dc.b    0
  14676. sound_II_onf_vin:
  14677.         dc.b    0
  14678. sound_II_onf_master:
  14679.         dc.b    0
  14680. sound_II_onf_kick:
  14681.         dc.b    0
  14682.  
  14683. sound_III_status:
  14684. sound_III_onf:    dc.b    0
  14685. sound_III_onf_bit:
  14686.         dc.b    0
  14687. sound_III_onf_master:
  14688.         dc.b    0
  14689. sound_III_onf_vin:
  14690.         dc.b    0
  14691.  
  14692. sound_IV_status:
  14693. sound_IV_onf:    dc.b    0
  14694. sound_IV_onf_vin:
  14695.         dc.b    0
  14696. sound_IV_onf_master:
  14697.         dc.b    0
  14698. sound_IV_onf_kick:
  14699.         dc.b    0
  14700.  
  14701. old_sound_I_duty:
  14702.         dc.b    0
  14703. old_sound_II_duty:
  14704.         dc.b    0
  14705.  
  14706. sound_I_pan:    dc.l    0
  14707. sound_II_pan:    dc.l    0
  14708. sound_III_pan:    dc.l    0
  14709. sound_IV_pan:    dc.l    0
  14710.  
  14711. sound_I_boost:    dc.l    0
  14712. sound_II_boost:    dc.l    0
  14713. sound_III_boost:dc.l    0
  14714. sound_IV_boost:    dc.l    0
  14715.  
  14716. sound_III_vol:    dc.l    0
  14717.         dc.l    $10000-2
  14718.         dc.l    $10000/2
  14719.         dc.l    $10000/4
  14720.  
  14721. sound_env_volumes:
  14722.         dc.l    0
  14723.         dc.l    (($10000/15)*1)-2
  14724.         dc.l    (($10000/15)*2)-2
  14725.         dc.l    (($10000/15)*3)-2
  14726.         dc.l    (($10000/15)*4)-2
  14727.         dc.l    (($10000/15)*5)-2
  14728.         dc.l    (($10000/15)*6)-2
  14729.         dc.l    (($10000/15)*7)-2
  14730.         dc.l    (($10000/15)*8)-2
  14731.         dc.l    (($10000/15)*9)-2
  14732.         dc.l    (($10000/15)*10)-2
  14733.         dc.l    (($10000/15)*11)-2
  14734.         dc.l    (($10000/15)*12)-2
  14735.         dc.l    (($10000/15)*13)-2
  14736.         dc.l    (($10000/15)*14)-2
  14737.         dc.l    (($10000/15)*15)-2
  14738.  
  14739. sound_III_lst:    dc.l    0
  14740.  
  14741. sound_III_f:    dc.w    0
  14742. sound_III_fh:    dc.b    0
  14743. sound_III_fl:    dc.b    0
  14744.  
  14745. sound_I_v:    dc.l    0
  14746. sound_II_v:    dc.l    0
  14747. sound_III_v:    dc.l    0
  14748. sound_IV_v:    dc.l    0
  14749.  
  14750. sound_I_f:    dc.w    0
  14751. sound_I_fh:    dc.b    0
  14752. sound_I_fl:    dc.b    0
  14753.  
  14754. sound_II_f:    dc.w    0
  14755. sound_II_fh:    dc.b    0
  14756. sound_II_fl:    dc.b    0
  14757.  
  14758. env_chnl_I:    dc.w    0
  14759.         dc.b    0
  14760. env_chnl_I_x:    dc.b    0
  14761.  
  14762. sound_II_ven:    dc.l    0
  14763. sound_II_ven_con:
  14764.         dc.l    0
  14765. sound_II_ven_all:
  14766.         dc.l    0
  14767.  
  14768. env_chnl_II:    dc.w    0
  14769.         dc.b    0
  14770. env_chnl_II_x:    dc.b    0
  14771.  
  14772. sound_IV_ven:    dc.l    0
  14773. sound_IV_ven_con:
  14774.         dc.l    0
  14775. sound_IV_ven_all:
  14776.         dc.l    0
  14777.  
  14778. env_chnl_IV:    dc.w    0
  14779.         dc.b    0
  14780. env_chnl_IV_x:    dc.b    0
  14781.  
  14782. enve_sweep_tbl:    dc.l    0
  14783.         dc.l    $8000/15-2+$8000
  14784.         dc.l    $8000/14-2+$8000
  14785.         dc.l    $8000/13-2+$8000
  14786.         dc.l    $8000/12-2+$8000
  14787.         dc.l    $8000/11-2+$8000
  14788.         dc.l    $8000/10-2+$8000
  14789.         dc.l    $8000/9-2+$8000
  14790.         dc.l    $8000/8-2+$8000
  14791.         dc.l    $8000/7-2+$8000
  14792.         dc.l    $8000/6-2+$8000
  14793.         dc.l    $8000/5-2+$8000
  14794.         dc.l    $8000/4-2+$8000
  14795.         dc.l    $8000/3-2+$8000
  14796.         dc.l    $8000/2-2+$8000
  14797.         dc.l    $8000-2+$8000
  14798.  
  14799. enve_sweep_val:    dc.l    0
  14800.         dc.l    (256*1)/60
  14801.         dc.l    (256*3)/60
  14802.         dc.l    (256*5)/60
  14803.         dc.l    (256*7)/60
  14804.         dc.l    (256*9)/60
  14805.         dc.l    (256*11)/60
  14806.         dc.l    (256*13)/60
  14807.  
  14808. sound_4_freq_table:
  14809.         dc.l    4194304/4
  14810.         dc.l    4194304/8
  14811.         dc.l    4194304/16
  14812.         dc.l    (4194304/8)/3
  14813.         dc.l    (4194304/8)/4
  14814.         dc.l    (4194304/8)/5
  14815.         dc.l    (4194304/8)/6
  14816.         dc.l    (4194304/8)/7
  14817.  
  14818. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14819. ;        $ffxx memory jump table
  14820. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14821.  
  14822. ffxx_jmp_table:    dc.l    do_joystick
  14823.         dc.l    sio_register
  14824.         dc.l    sio_control
  14825.         dc.l    gb_mem_wr
  14826.         dc.l    clear_divider
  14827.         dc.l    gb_mem_wr
  14828.         dc.l    gb_mem_wr
  14829.         dc.l    timc_protect
  14830.         dc.l    gb_mem_wr
  14831.         dc.l    gb_mem_wr
  14832.         dc.l    gb_mem_wr
  14833.         dc.l    gb_mem_wr
  14834.         dc.l    gb_mem_wr
  14835.         dc.l    gb_mem_wr
  14836.         dc.l    gb_mem_wr
  14837.         dc.l    irq_protect_0f                ;$0f.
  14838.  
  14839.         dc.l    rom_write
  14840.         dc.l    rom_write
  14841.         dc.l    rom_write
  14842.         dc.l    rom_write
  14843.         dc.l    rom_write
  14844.         dc.l    gb_mem_wr
  14845.         dc.l    rom_write
  14846.         dc.l    rom_write
  14847.         dc.l    rom_write
  14848.         dc.l    rom_write
  14849.         dc.l    rom_write
  14850.         dc.l    rom_write
  14851.         dc.l    rom_write
  14852.         dc.l    rom_write
  14853.         dc.l    rom_write
  14854.         dc.l    gb_mem_wr                ;$1f.
  14855.  
  14856.         dc.l    rom_write
  14857.         dc.l    rom_write
  14858.         dc.l    rom_write
  14859.         dc.l    rom_write
  14860.         dc.l    rom_write
  14861.         dc.l    rom_write
  14862.         dc.l    rom_write
  14863.         dc.l    gb_mem_wr
  14864.         dc.l    gb_mem_wr
  14865.         dc.l    gb_mem_wr
  14866.         dc.l    gb_mem_wr
  14867.         dc.l    gb_mem_wr
  14868.         dc.l    gb_mem_wr
  14869.         dc.l    gb_mem_wr
  14870.         dc.l    gb_mem_wr
  14871.         dc.l    gb_mem_wr                ;$2f.
  14872.  
  14873.         dc.l    rom_write
  14874.         dc.l    rom_write
  14875.         dc.l    rom_write
  14876.         dc.l    rom_write
  14877.         dc.l    rom_write
  14878.         dc.l    rom_write
  14879.         dc.l    rom_write
  14880.         dc.l    rom_write
  14881.         dc.l    rom_write
  14882.         dc.l    rom_write
  14883.         dc.l    rom_write
  14884.         dc.l    rom_write
  14885.         dc.l    rom_write
  14886.         dc.l    rom_write
  14887.         dc.l    rom_write
  14888.         dc.l    rom_write                ;$3f.
  14889.  
  14890.         dc.l    lcd_mode_write
  14891.         dc.l    lcd_protect
  14892.         dc.l    gb_mem_wr
  14893.         dc.l    gb_mem_wr
  14894.         dc.l    ly_write
  14895.         dc.l    lyc_write
  14896.         dc.l    dma_execute
  14897.         dc.l    gb_mem_wr
  14898.         dc.l    gb_mem_wr
  14899.         dc.l    gb_mem_wr
  14900.         dc.l    gb_mem_wr
  14901.         dc.l    gb_mem_wr
  14902.         dc.l    no_write
  14903.         dc.l    no_write
  14904.         dc.l    no_write
  14905.         dc.l    no_write                ;$4f.
  14906.  
  14907.         dc.l    no_write
  14908.         dc.l    no_write
  14909.         dc.l    no_write
  14910.         dc.l    no_write
  14911.         dc.l    no_write
  14912.         dc.l    no_write
  14913.         dc.l    no_write
  14914.         dc.l    no_write
  14915.         dc.l    no_write
  14916.         dc.l    no_write
  14917.         dc.l    no_write
  14918.         dc.l    no_write
  14919.         dc.l    no_write
  14920.         dc.l    no_write
  14921.         dc.l    no_write
  14922.         dc.l    no_write                ;$5f.
  14923.  
  14924.         dc.l    no_write
  14925.         dc.l    no_write
  14926.         dc.l    no_write
  14927.         dc.l    no_write
  14928.         dc.l    no_write
  14929.         dc.l    no_write
  14930.         dc.l    no_write
  14931.         dc.l    no_write
  14932.         dc.l    no_write
  14933.         dc.l    no_write
  14934.         dc.l    no_write
  14935.         dc.l    no_write
  14936.         dc.l    no_write
  14937.         dc.l    no_write
  14938.         dc.l    no_write
  14939.         dc.l    no_write                ;$6f.
  14940.  
  14941.         dc.l    no_write
  14942.         dc.l    no_write
  14943.         dc.l    no_write
  14944.         dc.l    no_write
  14945.         dc.l    no_write
  14946.         dc.l    no_write
  14947.         dc.l    no_write
  14948.         dc.l    no_write
  14949.         dc.l    no_write
  14950.         dc.l    no_write
  14951.         dc.l    no_write
  14952.         dc.l    no_write
  14953.         dc.l    no_write
  14954.         dc.l    no_write
  14955.         dc.l    no_write
  14956.         dc.l    no_write                ;$7f.
  14957.  
  14958.         dc.l    gb_mem_wr
  14959.         dc.l    gb_mem_wr
  14960.         dc.l    gb_mem_wr
  14961.         dc.l    gb_mem_wr
  14962.         dc.l    gb_mem_wr
  14963.         dc.l    gb_mem_wr
  14964.         dc.l    gb_mem_wr
  14965.         dc.l    gb_mem_wr
  14966.         dc.l    gb_mem_wr
  14967.         dc.l    gb_mem_wr
  14968.         dc.l    gb_mem_wr
  14969.         dc.l    gb_mem_wr
  14970.         dc.l    gb_mem_wr
  14971.         dc.l    gb_mem_wr
  14972.         dc.l    gb_mem_wr
  14973.         dc.l    gb_mem_wr                ;$8f.
  14974.  
  14975.         dc.l    gb_mem_wr
  14976.         dc.l    gb_mem_wr
  14977.         dc.l    gb_mem_wr
  14978.         dc.l    gb_mem_wr
  14979.         dc.l    gb_mem_wr
  14980.         dc.l    gb_mem_wr
  14981.         dc.l    gb_mem_wr
  14982.         dc.l    gb_mem_wr
  14983.         dc.l    gb_mem_wr
  14984.         dc.l    gb_mem_wr
  14985.         dc.l    gb_mem_wr
  14986.         dc.l    gb_mem_wr
  14987.         dc.l    gb_mem_wr
  14988.         dc.l    gb_mem_wr
  14989.         dc.l    gb_mem_wr
  14990.         dc.l    gb_mem_wr                ;$9f.
  14991.  
  14992.         dc.l    gb_mem_wr
  14993.         dc.l    gb_mem_wr
  14994.         dc.l    gb_mem_wr
  14995.         dc.l    gb_mem_wr
  14996.         dc.l    gb_mem_wr
  14997.         dc.l    gb_mem_wr
  14998.         dc.l    gb_mem_wr
  14999.         dc.l    gb_mem_wr
  15000.         dc.l    gb_mem_wr
  15001.         dc.l    gb_mem_wr
  15002.         dc.l    gb_mem_wr
  15003.         dc.l    gb_mem_wr
  15004.         dc.l    gb_mem_wr
  15005.         dc.l    gb_mem_wr
  15006.         dc.l    gb_mem_wr
  15007.         dc.l    gb_mem_wr                ;$af.
  15008.  
  15009.         dc.l    gb_mem_wr
  15010.         dc.l    gb_mem_wr
  15011.         dc.l    gb_mem_wr
  15012.         dc.l    gb_mem_wr
  15013.         dc.l    gb_mem_wr
  15014.         dc.l    gb_mem_wr
  15015.         dc.l    gb_mem_wr
  15016.         dc.l    gb_mem_wr
  15017.         dc.l    gb_mem_wr
  15018.         dc.l    gb_mem_wr
  15019.         dc.l    gb_mem_wr
  15020.         dc.l    gb_mem_wr
  15021.         dc.l    gb_mem_wr
  15022.         dc.l    gb_mem_wr
  15023.         dc.l    gb_mem_wr
  15024.         dc.l    gb_mem_wr                ;$bf.
  15025.  
  15026.         dc.l    gb_mem_wr
  15027.         dc.l    gb_mem_wr
  15028.         dc.l    gb_mem_wr
  15029.         dc.l    gb_mem_wr
  15030.         dc.l    gb_mem_wr
  15031.         dc.l    gb_mem_wr
  15032.         dc.l    gb_mem_wr
  15033.         dc.l    gb_mem_wr
  15034.         dc.l    gb_mem_wr
  15035.         dc.l    gb_mem_wr
  15036.         dc.l    gb_mem_wr
  15037.         dc.l    gb_mem_wr
  15038.         dc.l    gb_mem_wr
  15039.         dc.l    gb_mem_wr
  15040.         dc.l    gb_mem_wr
  15041.         dc.l    gb_mem_wr                ;$cf.
  15042.  
  15043.         dc.l    gb_mem_wr
  15044.         dc.l    gb_mem_wr
  15045.         dc.l    gb_mem_wr
  15046.         dc.l    gb_mem_wr
  15047.         dc.l    gb_mem_wr
  15048.         dc.l    gb_mem_wr
  15049.         dc.l    gb_mem_wr
  15050.         dc.l    gb_mem_wr
  15051.         dc.l    gb_mem_wr
  15052.         dc.l    gb_mem_wr
  15053.         dc.l    gb_mem_wr
  15054.         dc.l    gb_mem_wr
  15055.         dc.l    gb_mem_wr
  15056.         dc.l    gb_mem_wr
  15057.         dc.l    gb_mem_wr
  15058.         dc.l    gb_mem_wr                ;$df.
  15059.  
  15060.         dc.l    gb_mem_wr
  15061.         dc.l    gb_mem_wr
  15062.         dc.l    gb_mem_wr
  15063.         dc.l    gb_mem_wr
  15064.         dc.l    gb_mem_wr
  15065.         dc.l    gb_mem_wr
  15066.         dc.l    gb_mem_wr
  15067.         dc.l    gb_mem_wr
  15068.         dc.l    gb_mem_wr
  15069.         dc.l    gb_mem_wr
  15070.         dc.l    gb_mem_wr
  15071.         dc.l    gb_mem_wr
  15072.         dc.l    gb_mem_wr
  15073.         dc.l    gb_mem_wr
  15074.         dc.l    gb_mem_wr
  15075.         dc.l    gb_mem_wr                ;$ef.
  15076.  
  15077.         dc.l    gb_mem_wr
  15078.         dc.l    gb_mem_wr
  15079.         dc.l    gb_mem_wr
  15080.         dc.l    gb_mem_wr
  15081.         dc.l    gb_mem_wr
  15082.         dc.l    gb_mem_wr
  15083.         dc.l    gb_mem_wr
  15084.         dc.l    gb_mem_wr
  15085.         dc.l    gb_mem_wr
  15086.         dc.l    gb_mem_wr
  15087.         dc.l    gb_mem_wr
  15088.         dc.l    gb_mem_wr
  15089.         dc.l    gb_mem_wr
  15090.         dc.l    gb_mem_wr
  15091.         dc.l    gb_mem_wr
  15092.         dc.l    irq_protect_ff                ;$ff.
  15093.  
  15094. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15095. ;        memory lists
  15096. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15097.  
  15098. list_default:    dc.l    0
  15099. list_aga:    dc.l    0
  15100. list_screen:    dc.l    0
  15101. list_window:    dc.l    0
  15102.  
  15103. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15104. ;        the memory allocation lists
  15105. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15106.  
  15107. list_default_structure:
  15108.  
  15109.         IFGT    GAMEBOY_SERIAL
  15110.  
  15111.         dc.l    io_buffer_in,64,MEMF_PUBLIC!MEMF_CLEAR
  15112.         dc.l    io_buffer_out,64,MEMF_PUBLIC!MEMF_CLEAR
  15113.  
  15114.         ENDIF
  15115.  
  15116.         dc.l    info_map_attr,bm_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15117.         dc.l    about_map_attr,bm_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15118.         dc.l    back_pattern_map_attr,bm_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15119.  
  15120.         dc.l    back_pattern_map,function_x/8*function_y*2,MEMF_CHIP!MEMF_CLEAR
  15121.         dc.l    info_map,function_x/8*function_y*8,MEMF_CHIP!MEMF_CLEAR
  15122.         dc.l    about_map,function_x/8*function_y*8,MEMF_CHIP!MEMF_CLEAR
  15123.  
  15124.         dc.l    univ_gadget,gng_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15125.         dc.l    gb_memory,$10000,MEMF_PUBLIC!MEMF_CLEAR
  15126.         dc.l    memory_banks,131072+XPK_MARGIN+$2000,MEMF_PUBLIC
  15127.         dc.l    x_flip_table,$10000*2,MEMF_PUBLIC
  15128.         dc.l    snapshot_area,$2000*16+$8000+1024+XPK_MARGIN,MEMF_PUBLIC
  15129.         dc.l    gb_mem_jumps,$10000*4,MEMF_PUBLIC
  15130.  
  15131.         dc.l    name_ptr,256,MEMF_PUBLIC!MEMF_CLEAR
  15132.         dc.l    dir_n_name_ptr,256*2,MEMF_PUBLIC!MEMF_CLEAR
  15133.         dc.l    def_dir,256,MEMF_PUBLIC!MEMF_CLEAR
  15134.         dc.l    def_ss_dir,256,MEMF_PUBLIC!MEMF_CLEAR
  15135.         dc.l    file_info_ptr,fib_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15136.         dc.l    xpk_names,1024,MEMF_PUBLIC!MEMF_CLEAR
  15137.  
  15138.         dc.l    ahi_mode_txt,128,MEMF_PUBLIC!MEMF_CLEAR
  15139.         dc.l    smpl_mem_1,8*512,MEMF_PUBLIC
  15140.         dc.l    smpl_mem_2,8*512,MEMF_PUBLIC
  15141.         dc.l    smpl_mem_3,8*512,MEMF_PUBLIC
  15142.         dc.l    smpl_mem_4,8*512,MEMF_PUBLIC
  15143.         dc.l    smpl_III_mem,32,MEMF_PUBLIC
  15144.         dc.l    sound_III_lst,256*2,MEMF_PUBLIC
  15145.         dc.l    smpl_info_I,AHISampleInfo_SIZEOF,MEMF_PUBLIC
  15146.         dc.l    smpl_info_II,AHISampleInfo_SIZEOF,MEMF_PUBLIC
  15147.         dc.l    smpl_info_III,AHISampleInfo_SIZEOF,MEMF_PUBLIC
  15148.         dc.l    smpl_info_IV,AHISampleInfo_SIZEOF,MEMF_PUBLIC
  15149.  
  15150.         dc.l    joy_names_list,(LN_SIZE+2)*6,MEMF_PUBLIC!MEMF_CLEAR
  15151.         dc.l    prefs_file,2048,MEMF_PUBLIC!MEMF_CLEAR
  15152.         dc.l    prefs_file_rom,128,MEMF_PUBLIC
  15153.         dc.l    joy_label_list,LH_SIZE,MEMF_PUBLIC!MEMF_CLEAR
  15154.         dc.l    xpk_label_list,LH_SIZE,MEMF_PUBLIC!MEMF_CLEAR
  15155.         dc.l    gg_label_list,LH_SIZE,MEMF_PUBLIC!MEMF_CLEAR
  15156.         dc.l    gg_dummy_item,LN_SIZE+2,MEMF_PUBLIC!MEMF_CLEAR
  15157.         dc.l    colour_message,MN_SIZE+8*3,MEMF_PUBLIC!MEMF_CLEAR
  15158.         dc.l    colour_message_name,256,MEMF_PUBLIC!MEMF_CLEAR
  15159.         dc.l    menu_favo_nf,32*20,MEMF_PUBLIC!MEMF_CLEAR
  15160.  
  15161.         dc.l    gfx_game_still_array,((((304+15)/16)*16)*(39+1)),MEMF_PUBLIC
  15162.         dc.l    gfx_game_still_tmp_array,((((304+15)/16)*16)*(39+1)),MEMF_PUBLIC
  15163.         dc.l    gfx_game_still_rast_port,rp_SIZEOF,MEMF_PUBLIC
  15164.         dc.l    gfx_game_still_tmp_rast_port,rp_SIZEOF,MEMF_PUBLIC
  15165.         dc.l    gfx_game_still_map_attr,bm_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15166.  
  15167.         dc.l    keyboard_io,IOSTD_SIZE,MEMF_PUBLIC!MEMF_CLEAR
  15168.         dc.l    keyboard_matrix,16,MEMF_PUBLIC!MEMF_CLEAR
  15169.  
  15170.         dc.l    prefs_str_1,256,MEMF_PUBLIC!MEMF_CLEAR
  15171.         dc.l    prefs_str_2,256,MEMF_PUBLIC!MEMF_CLEAR
  15172.         dc.l    prefs_str_3,256,MEMF_PUBLIC!MEMF_CLEAR
  15173.         dc.l    prefs_str_4,256,MEMF_PUBLIC!MEMF_CLEAR
  15174.  
  15175.         dc.l    aga_sprs_cI,256,MEMF_PUBLIC!MEMF_CLEAR
  15176.         dc.l    aga_sprs_cII,256,MEMF_PUBLIC!MEMF_CLEAR
  15177.         dc.l    aga_sprs_cxI,256,MEMF_PUBLIC!MEMF_CLEAR
  15178.         dc.l    aga_sprs_cxII,256,MEMF_PUBLIC!MEMF_CLEAR
  15179.  
  15180.         dc.l    context_g_menu,gg_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15181.         dc.l    context_g_sfx,gg_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15182.         dc.l    context_g_prefs,gg_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15183.         dc.l    context_g_gfx,gg_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15184.         dc.l    context_g_misc,gg_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15185.  
  15186.         dc.l    misc_str_1,32,MEMF_PUBLIC!MEMF_CLEAR
  15187.         dc.l    misc_str_2,32,MEMF_PUBLIC!MEMF_CLEAR
  15188.         dc.l    misc_str_3,32,MEMF_PUBLIC!MEMF_CLEAR
  15189.  
  15190.         dc.l    dimension_info,dim_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15191.  
  15192.         dc.l    0
  15193.  
  15194. list_aga_structure:
  15195.         dc.l    copper_I,8192,MEMF_CHIP!MEMF_CLEAR
  15196.         dc.l    aga_map_I,320/8*256*8,MEMF_CHIP!MEMF_CLEAR
  15197.         dc.l    aga_map_II,320/8*256*8,MEMF_CHIP!MEMF_CLEAR
  15198.         dc.l    aga_col_bg,2*2*4*256,MEMF_PUBLIC!MEMF_CLEAR
  15199.         dc.l    aga_col_sprs,2*2*4*256,MEMF_PUBLIC!MEMF_CLEAR
  15200.         dc.l    aga_ro_list_I,256,MEMF_PUBLIC!MEMF_CLEAR
  15201.         dc.l    aga_ro_list_II,256,MEMF_PUBLIC!MEMF_CLEAR
  15202.  
  15203.         dc.l    aga_spr_Ia,sprite_memory,MEMF_CHIP!MEMF_CLEAR
  15204.         dc.l    aga_spr_IIa,sprite_memory,MEMF_CHIP!MEMF_CLEAR
  15205.         dc.l    aga_spr_IIIa,sprite_memory,MEMF_CHIP!MEMF_CLEAR
  15206.         dc.l    aga_spr_Ib,sprite_memory,MEMF_CHIP!MEMF_CLEAR
  15207.         dc.l    aga_spr_IIb,sprite_memory,MEMF_CHIP!MEMF_CLEAR
  15208.         dc.l    aga_spr_IIIb,sprite_memory,MEMF_CHIP!MEMF_CLEAR
  15209.         dc.l    aga_spr_Ix,sprite_memory,MEMF_CHIP!MEMF_CLEAR
  15210.         dc.l    aga_spr_IIx,sprite_memory,MEMF_CHIP!MEMF_CLEAR
  15211.         dc.l    aga_spr_IIIx,sprite_memory,MEMF_CHIP!MEMF_CLEAR
  15212.         dc.l    aga_spr_empty,sprite_memory,MEMF_CHIP!MEMF_CLEAR
  15213.  
  15214.         dc.l    0
  15215.  
  15216. list_screen_structure:
  15217.         dc.l    gb_rport_I,rp_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15218.         dc.l    gb_rport_II,rp_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15219.         dc.l    gb_bmap_I,bm_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15220.         dc.l    gb_bmap_II,bm_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15221. screen_chip_1:    dc.l    gb_bplanes_I,gb_screen_x/8*gb_screen_y*4,MEMF_CHIP
  15222. screen_chip_2:    dc.l    gb_bplanes_II,gb_screen_x/8*gb_screen_y*4,MEMF_CHIP
  15223.  
  15224.         dc.l    game_tmp_rast_port,rp_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15225.  
  15226.         dc.l    game_array,((((160+15)/16)*16)*(144+1)),MEMF_PUBLIC
  15227.  
  15228.         dc.l    0
  15229.  
  15230. list_window_structure:
  15231.         dc.l    wzonka_map_attr,bm_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15232. window_chip_1:    dc.l    wzonka_map,gb_screen_x/8*gb_screen_y*4,MEMF_CHIP!MEMF_CLEAR
  15233.  
  15234.         dc.l    game_rast_port,rp_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15235.         dc.l    game_tmp_rast_port,rp_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15236.         dc.l    game_output_tmp_rast_port,rp_SIZEOF,MEMF_PUBLIC!MEMF_CLEAR
  15237.  
  15238.         dc.l    game_array,((((160+15)/16)*16)*(144+1)),MEMF_PUBLIC
  15239.         dc.l    game_scale_array,(480+24)*(432+24),MEMF_PUBLIC
  15240.  
  15241.         dc.l    pen_conversion_table,$1616*2,MEMF_PUBLIC
  15242.  
  15243.         dc.l    0
  15244.  
  15245. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15246. ;        universal window values
  15247. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15248.  
  15249. window_bars_height:
  15250.         dc.l    0
  15251. window_bars_width:
  15252.         dc.l    0
  15253.  
  15254. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15255. ;        status texts
  15256. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15257.  
  15258. old_status_text:dc.l    0
  15259.  
  15260. emulator_status_text:
  15261.         dc.b    0
  15262.         dc.b    0
  15263.         dc.b    0
  15264.         dc.b    0
  15265.         dc.w    0                ;x is computed.
  15266.         dc.w    83+7
  15267.         dc.l    font_attr
  15268. emulator_status_txt:
  15269.         dc.l    0
  15270.         dc.l    0
  15271.  
  15272. status_waiting_txt:
  15273.         dc.b    "> Load a ROM <",0
  15274.         even
  15275. status_rom_loaded_txt:
  15276.         dc.b    "> ROM loaded <",0
  15277.         even
  15278. status_rom_reset_txt:
  15279.         dc.b    "> ROM reset <",0
  15280.         even
  15281. status_gbs_loaded_txt:
  15282.         dc.b    "> RAM snapshot loaded <",0
  15283.         even
  15284. status_running_txt:
  15285.         dc.b    "> Executing ROM <",0
  15286.         even
  15287. status_paused_txt:
  15288.         dc.b    "> Emulation paused <",0
  15289.         even
  15290. status_file_not_found_txt:
  15291.         dc.b    "> File not found <",0
  15292.         even
  15293. status_xpk_error_txt:
  15294.         dc.b    "> XPK error <",0
  15295.         even
  15296. status_not_enough_memory_txt:
  15297.         dc.b    "> Not enough memory <",0
  15298.         even
  15299. status_too_big_a_file_txt:
  15300.         dc.b    "> Too big a file <",0
  15301.         even
  15302. status_xpk_pack_txt:
  15303.         dc.b    "> XPK ("
  15304. status_xpk_name_txt:
  15305.         dc.b    "NNNN) packing <",0
  15306.         even
  15307. status_xpk_unpack_txt:
  15308.         dc.b    "> XPK ("
  15309. status_xpk_name_u_txt:
  15310.         dc.b    "NNNN) unpacking <",0
  15311.         even
  15312. status_file_saved_txt:
  15313.         dc.b    "> Data saved <",0
  15314.         even
  15315. status_file_saved_error_txt:
  15316.         dc.b    "> Error in data saving <",0
  15317.         even
  15318. status_invalid_patch_txt:
  15319.         dc.b    "> Invalid GameGenie patch code <",0
  15320.         even
  15321. status_patch_none_txt:
  15322.         dc.b    "> Patch doesn't apply to this ROM <",0
  15323.         even
  15324. status_rom_patched_txt:
  15325.         dc.b    "> ROM patched <",0
  15326.         even
  15327. status_no_rom_txt:
  15328.         dc.b    "> No ROM to patch <",0
  15329.         even
  15330. status_corrupted_rom_txt:
  15331.         dc.b    "> Corrupted ROM file <",0
  15332.         even
  15333. status_cant_open_window_txt:
  15334.         dc.b    "> Can't open auxiliary window <",0
  15335.         even
  15336. status_unknown_rom_size_txt:
  15337.         dc.b    "> Unknown ROM size <",0
  15338.         even
  15339.  
  15340. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15341. ;        gamegenie
  15342. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15343.  
  15344. gg_patch:    dc.b    "PATCHME!!"
  15345.         even
  15346.  
  15347. gg_list:    dc.l    0
  15348. gg_list_size:    dc.l    0
  15349. gg_linked_list:    dc.l    0
  15350. gg_linked_list_last_item:
  15351.         dc.l    0
  15352.  
  15353. gg_list_name:    dc.b    "PROGDIR:game_genie/game_genie.list",0
  15354.         even
  15355.  
  15356. gg_dummy_item_txt:
  15357.         dc.b    "None",0
  15358.         even
  15359.  
  15360. gg_rom_name:    dc.l    0
  15361.  
  15362. gg_register_1_txt:
  15363.         dc.b    "REG",0
  15364.         even
  15365.  
  15366. gg_register_2_txt:
  15367.         dc.b    "IST",0
  15368.         even
  15369.  
  15370. gg_register_3_txt:
  15371.         dc.b    "ER!",0
  15372.         even
  15373.  
  15374. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15375. ;        ntsc/pal screen
  15376. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15377.  
  15378. block_screen_taglist:
  15379.         dc.l    SA_Width,160
  15380.         dc.l    SA_Height,144
  15381.         dc.l    SA_Depth,1
  15382.         dc.l    SA_BlockPen,1
  15383.         dc.l    SA_DetailPen,0
  15384.         dc.l    SA_Type,PUBLICSCREEN
  15385.         dc.l    SA_AutoScroll,FALSE
  15386.         dc.l    SA_ShowTitle,FALSE
  15387.         dc.l    SA_Behind,FALSE
  15388.         dc.l    SA_Quiet,TRUE
  15389. block_screen_id:dc.l    SA_DisplayID,PAL_MONITOR_ID!LORES_KEY
  15390.         dc.l    SA_Draggable,FALSE
  15391.         dc.l    SA_Interleaved,FALSE
  15392.         dc.l    TAG_END,0
  15393.  
  15394. block_screen_ptr:
  15395.         dc.l    0
  15396.  
  15397. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15398. ;        unsorted byte values
  15399. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15400.  
  15401. old_render:    dc.b    0
  15402. old_refresh:    dc.b    0
  15403. scaling_status:    dc.b    0
  15404. refresh_scanline:
  15405.         dc.b    0
  15406. sfx_volume_value:
  15407.         dc.b    0
  15408. aga_mode:    dc.b    0
  15409. pck_xpk_status:    dc.b    0
  15410. pck_method_number:
  15411.         dc.b    0
  15412. battery_status:    dc.b    0
  15413. battery_xpk_status:
  15414.         dc.b    0
  15415. keystick:    dc.b    0
  15416. sfx_y_update:    dc.b    0
  15417.  
  15418. old_led:    dc.b    0
  15419. back_ground_colour_byte:
  15420.         dc.b    0
  15421. gfx_values_need_update:
  15422.         dc.b    0
  15423.                 even
  15424.  
  15425. sfx_y_actual_value:
  15426.         dc.l    0
  15427. sfx_y_adder:    dc.l    0
  15428.  
  15429. cartridge_status:
  15430.         dc.b    0
  15431. cli_or_wb:    dc.b    0
  15432. load_or_reset:    dc.b    0
  15433.  
  15434. forbid_permit_status:
  15435.         dc.b    0
  15436. os_screen_speed_limit:
  15437.         dc.b    0
  15438. fast_ram_bitmaps:
  15439.         dc.b    0
  15440.  
  15441. obtain_status_counter:
  15442.         dc.b    4
  15443. colour_load_status:
  15444.         dc.b    0
  15445.  
  15446. rom_type:    dc.b    0
  15447.  
  15448. irq_status_flags:
  15449.         dc.b    0
  15450. transfer_counter:
  15451.         dc.b    0
  15452.  
  15453. misc_b_code_list_selected:
  15454.         dc.b    0
  15455. gg_code_status:    dc.b    0
  15456.         even
  15457.  
  15458. four_ram_banks_from_gbs:
  15459.         dc.l    0
  15460.  
  15461. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15462. ;        debug
  15463. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15464.  
  15465.         IFGT    GAMEBOY_DEBUG
  15466.  
  15467. debug_consol_name:
  15468. ;        dc.b    "CON:0/11/640/200/Wzonka-Lad Debug",0
  15469.         dc.b    "T:Wzonka-Lad.DEBUG",0
  15470.         even
  15471.  
  15472. debug_exit:    dc.b    0
  15473. rom_bank_activated:
  15474.         dc.b    0
  15475. ram_bank_activated:
  15476.         dc.b    0
  15477.         even
  15478.  
  15479. debug_con_handle:
  15480.         dc.l    0
  15481.  
  15482. gbz80_de:    dc.w    0
  15483. gbz80_bc:    dc.w    0
  15484. gbz80_hl:    dc.w    0
  15485. gbz80_fa:    dc.w    0
  15486.  
  15487. debug_message:    dc.b    "AF="
  15488. debug_af:    dc.b    "nnnn "
  15489.         dc.b    "BC="
  15490. debug_bc:    dc.b    "nnnn "
  15491.         dc.b    "DE="
  15492. debug_de:    dc.b    "nnnn "
  15493.         dc.b    "HL="
  15494. debug_hl:    dc.b    "nnnn "
  15495.         dc.b    "PC="
  15496. debug_pc:    dc.b    "nnnn "
  15497.         dc.b    "SP="
  15498. debug_sp:    dc.b    "nnnn "
  15499.         dc.b    "CL="
  15500. debug_cycles:    dc.b    "nnnn "
  15501.         dc.b    "OC="
  15502. debug_oc:    dc.b    "nn   "
  15503. debug_flags:    dc.b    "-----",$a            ;znhci.
  15504. debug_command:    dc.b    "                "
  15505.         dc.b    " x="
  15506. debug_next_1:    dc.b    "nn   "
  15507.         dc.b    "xx="
  15508. debug_next_2:    dc.b    "nnnn "
  15509.         dc.b    "OB="
  15510. debug_rom_bank:    dc.b    "nn   "
  15511.         dc.b    "AB="
  15512. debug_ram_bank:    dc.b    "nn   ",$a
  15513. debug_message_end:
  15514.         even
  15515.  
  15516.         ds.b    256
  15517.  
  15518. debug_scanline_message:
  15519.         dc.b    "*** NEXT SCANLINE: "
  15520. debug_scanline:    dc.b    "nnnn",$a
  15521. debug_scanline_message_end:
  15522.         even
  15523.  
  15524. debug_vbr_txt:    dc.b    "*** VBR IRQ",$a
  15525. debug_vbr_txt_end:
  15526.         even
  15527.  
  15528. debug_lcd_txt:    dc.b    "*** LCD STATE IRQ",$a
  15529. debug_lcd_txt_end:
  15530.         even
  15531.  
  15532. debug_p10_txt:    dc.b    "*** P10 IRQ",$a
  15533. debug_p10_txt_end:
  15534.         even
  15535.  
  15536. debug_timer_txt:dc.b    "*** TIMER IRQ",$a
  15537. debug_timer_txt_end:
  15538.         even
  15539.  
  15540. debug_blank_txt:dc.b    "*** LCD LINE CMP IRQ",$a
  15541. debug_blank_txt_end:
  15542.         even
  15543.  
  15544. debug_joy_txt:    dc.b    "*** -> $FF00: "
  15545. debug_joy:    dc.b    "nn",$a
  15546. debug_joy_txt_end:
  15547.         even
  15548.  
  15549.         include    "debug_optcode_list.i"
  15550.  
  15551.         ENDIF
  15552.  
  15553. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15554. ;        poitner tags
  15555. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15556.  
  15557. pause_pointer_tags:
  15558.         dc.l    WA_Pointer, 0
  15559.         dc.l    WA_BusyPointer, TRUE
  15560.         dc.l    TAG_END,0
  15561.  
  15562. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15563. ;        serial data
  15564. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15565.  
  15566.         IFGT    GAMEBOY_SERIAL
  15567.  
  15568. serial_device_name:
  15569.         dc.b    "8n1.device",0
  15570.         even
  15571.  
  15572. io_request_in:    dc.l    0
  15573. io_request_out:    dc.l    0
  15574. io_buffer_in:    dc.l    0
  15575. io_buffer_out:    dc.l    0
  15576.  
  15577. input_message_port:
  15578.         dc.l    0
  15579. output_message_port:
  15580.         dc.l    0
  15581.  
  15582. serial_device_status:
  15583.         dc.b    0
  15584.         even
  15585.  
  15586.         ENDIF
  15587.  
  15588. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15589. ;        EI
  15590. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15591.  
  15592. z80_cycles_left:dc.l    0
  15593. z80_ei_return:    dc.b    0
  15594.         even
  15595.  
  15596. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15597.         section    displayable_images,data_c
  15598. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  15599.  
  15600. gfx_game_still_map:
  15601.         incbin    "data/gfx_game_still_map.bn"
  15602.         even
  15603.  
  15604.         END
  15605.